Any vs Java Wildcard



I’m using a Java Reflections API ( that returns a Set of Class<?> (Set>), i trying to assign the returned Set to a Class property declared by:

  `var serverClasses : Set<Class<Any>> = hashSetOf<Class<Any>>();`

And i’m getting this error:

Type mismatch.
Required: Set<Class>
Found: (Mutable)Set<Class<*>!>!

Klotin “Any” keyword is similar to Java Generics Wildcard?

Thank you!!!


Any corresponds to java.lang.Object, not to a wildcard.

Please refer to