I faced this issue and hence posting it as complete solution -
With Java 8, the below code will fail with Runtime exception. The problem is getInteger method is returning a generic Integer type and print method expects exact Object Type.
public static void main(String[] args) {
print(getInteger());
}
private static <T> T getInteger() {
return (T)new Integer(10);
}
private static void print(Object...o1){
for(Object o: o1){
System.out.println(o);
}
}