Java generics: What is the compiler's issue here?

Posted by Epaga on Stack Overflow See other posts from Stack Overflow or by Epaga
Published on 2010-03-12T08:25:50Z Indexed on 2010/03/12 8:27 UTC
Read the original article Hit count: 826

Filed under:
|
|

I have the following methods:

public <T> T fromJson( Reader jsonData, Class<T> clazz ) {
    return fromJson( jsonData, (Type)clazz );
}

public <T> T fromJson( Reader jsonData, Type clazz ) {
    ...
}

The compiler is saying about the first method:

 type parameters of <T>T cannot be determined;
 no unique maximal instance exists for type variable T
 with upper bounds T,java.lang.Object

 return fromJson( jsonData, (Type)clazz );
                ^

What is the problem?

© Stack Overflow or respective owner

Related posts about java

Related posts about compiler