Does Class<SomeObject>
have only one instance which is SomeObject.class
?
That is to a function
void f(Class<SomeObject> arg)
is it possible to pass only SomeObject.class
otherwise compile time error?
You can always pass null
, but barring that, yes the only valid parameter would be SomeObject.class
which is loaded with the same ClassLoader
as the class that contains void f(Class<SomeObject> clazz)
.
You can have multiple distinct instances of SomeObject.class
, but they will need to be loaded by different classloaders (otherwise they will not be separate instances, but all will refer to the same Class object).
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments