mardi 12 mai 2015

How to use generic in Class.class

I want to avoid the warning:

"type safety the expression of type needs unchecked conversion to conform to Class"

From this sentence:

Class<MyInterface> cc = interpreter.get("Myclass", Class.class );

I have tried:

Class<MyInterface> cc = interpreter.get("Myclass", Class<MyInterface>.class );

But is invalid.

How can I do that without @SuppressWarnings("unchecked")

The signature of

T interpreter.get(String name, Class<T> javaClass)





Aucun commentaire:

Enregistrer un commentaire