Cannot import operations for implementation classes with wildcards

Issue #464 new
Matthias Schoettle created an issue

If java.lang.Class is imported and its getClass() operation imported, because it returns a Class<?>, this type is also imported. However, implementation class Class<?> does not allow to have operations imported.

Instead, it should allow to import operations, because it is possible to call operations on an instance of Class<?>. What Java seems to be doing is to return or take Object where just T is used in the signature. Whereas Class<T> stays as Class<?>.

For example:

  • newInstance() : T will return Object
  • cast(Object) : T will return Object
  • getTypeParameters() : TypeVariable<Class<T>>[] will return TypeVariable<Class<?>>[]

One thing that makes it harder to change this is that in the model, the TypeParameter's name for the wildcard is changed from T to ?, instead of somehow using the reference to generic type. This makes it hard to make sure that the correct type parameter of the Java class is the one that is a wildcard. Maybe it would be better to do a TypeParameter with the correct name, but genericType refers to our RAny type instance.

Comments (0)

  1. Log in to comment