To create a Java method with a generic return type one can write a method like this.
protected static <T> T evaluateExpression(String tagName, String attributeName, String attributeValue, Â Class<T> expectedType, Tag tagRef, PageContext pageContext)
You can learn more at this Java Generics FAQ.