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