AnonymousClassLoader in JRuby
Rémi Forax
forax at univ-mlv.fr
Sun Apr 27 03:34:19 PDT 2008
Charles Oliver Nutter a écrit :
> Rémi Forax wrote:
>> In my opinion, there is one AnonymousClassloader by host class to
>> share security check.
>
> I'm not sure I see how to use a single java.dyn.AnonymousClassLoader
> to load multiple classes, since it seems to want the class bytes on
> construction. Looking at source now.
First, the AnonymousClassLoader in the hg repository has several
limitations.
See the thread:
http://mail.openjdk.java.net/pipermail/mlvm-dev/2008-April/000056.html
*Be it as it may*, the AnonymousClassLoader only takes an hostClass at
construction.
And you can use setClassFile() and then loadClass() to load an anonymous
class.
You perhaps browse the source code too kickly,
the constructors are definined in the middle of the file not in the
beginning,
it's trouble me too the first time i've read that code.
>
>> Else, why do you use reflection in org.jruby.util.AnonymousClassLoader ?
>
> The reflection stuff is just to isolate pre-DVM JDKs from
> java.dyn.AnonymousClasLoader. It would probably be replaced with a
> pluggable mechanism of some kind. So it's essentially the same as what
> you have, but backward compatible.
Ok, you want to be able to compile the sources without the package java.dyn.
I've perhaps found why there is no difference in your test.
I've re-read the code of your ruby Classoader and someting is weird,
the last instruction of the static block should be
ANONYMOUS_SUPPORTED = true;
and not
ANONYMOUS_SUPPORTED = false;
cheers,
Rémi
More information about the mlvm-dev
mailing list