Rémi Forax wrote: > 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.
An interesting thought. I can think of a few places I expect to be able to call getClassLoader on a target class I've loaded at runtime, but that's generally because I want to associate other classes dependent on the target class (i.e. method handles for a freshly-loaded compiled Ruby script) with the same throwaway classloader. Given the looser nature of the anonymous classloader, that particular scenario would go away. I'd just always grab my trust anonymous classloader and throw classes at it, knowing they'd GC when they were no longer in use. I don't think the anonymous classloader is going to be something you can just start using lightly, since assumptions existing classes make about classloading are sure to get in the way. - Charlie _______________________________________________ mlvm-dev mailing list [email protected] http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev
