To create a Java method with a generic return type one can write a method like this.

  protected static  T evaluateExpression(String tagName, String attributeName,
      String attributeValue, Class expectedType, Tag tagRef, PageContext pageContext)

You can learn more at this Java Generics FAQ.