AnonymousClassLoader and ClassLoader

Rémi Forax forax at univ-mlv.fr
Thu Apr 24 04:43:42 PDT 2008


Rémi Forax a écrit :
> Yesterday evening, I've tried to replace the application classloader
> (the one used to load the application) by one that use an anymous class 
> loader
> to load the class. And i've tested by launching SwingSet2.
>
> And it doesn't work because UI program  like SwingSet  lookup their 
> resources
> like image, icons etc. using getResource()/getResourceAsStream().
> getResource() makes the assumption that if getClassLoader() returns null
> the class is loaded by the bootstrap classloader.
>
> In my opinion, getResource() is not the only method that makes this 
> assumption
> so an anonymous class should be able to specify an external classloader
> when defined i.e. Unsafe.defineAnonymousClass should take
> a classloader as argument.
>
> Rémi
>   

I answer to myself, it's only in the case the host-class is null,
otherwise the classloader used is the one of the host-class.

What is exactly the meaning of a null host-class ?

Rémi



More information about the mlvm-dev mailing list