Aha, now I remember. Thanks.
I wanted to supply the bcel classLoader as the system classloader like:

java -Djava.system.class.loader=org.apache.bcel.util.ClassLoader MyClass

This doesn't work because the empty constructor of org..ClassLoader instatiates a default member deferTo:

private java.lang.ClassLoader deferTo = ClassLoader.getSystemClassLoader();

getSystemClassLoader will try to construct org..ClassLoader (because we supplied java.system.class.loader) which will try to instatiate deferTo which... etc, etc.

The trouble is that you can't prevent this behaviour. You could call a constructor with a deferTo as a parameter (getParent() would be a good choice), but it's too late, the loop will loop.
The good thing is.... it's Open Source ;)


If deferTo would be left uninstantiated and they'd made sure every constructor would set deferTo to something logical:
*first* try getParent() if that returns null (which JVM implementation MAY do according to the specs)
*then* try getSystemClassLoader (which may result in an IllegalStateException that can be caught).
If everything fails you can't defer, and ignored package names would be meaningless and they also have to be loaded by the ClassParser which is tricky. Luckily both the Sun JVM and IBM JVM return a default ClassLoader when getParent() is called.


I'll post this message to the bcel-dev list and hopefully they'll pick it up.

Also, I don't know of other bcel-like projects that have ClassLoader implementations have the same problems. You can always try some out. I think AspectWerkz uses ObjectWeb ASM which is smaller and faster but looks a lot harder to use. And there are a few other projects out there...

Good luck, and let me know if you stumble upon things you might think I might find interesting (which is not an invitation for spam, obviously :D)

Matthijs.


LERBSCHER Jean-Pierre wrote:

Thanks Matthijs.
This is your post on bcel mailing list.
http://www.mail-archive.com/bcel-dev@jakarta.apache.org/msg00382.html


-----Message d'origine-----
De : Matthijs Wensveen [mailto:[EMAIL PROTECTED] Envoyé : vendredi 21 janvier 2005 11:31
À : LERBSCHER Jean-Pierre
Objet : Re: BCEL ClassLoader



Hello Jean-Pierre,
Can you refresh my memory? It's been a while since I posted a question on the mailing list and you mail doesn't include any context. I'm not
working on classloaders anymore since AspectWerkz solved the problem I was working on. But I do remember solving some problems I had with BCEL. I believe it had something to do with the classloader needing to load all subsequent classes (bootstrapping classloader). If I can find the source code I was working on I will mail it to you. Unfortunately I will be gone tonight and for the weekend, so it will be monday at the earliest. I hope this is okay.


Regards,
Matthijs.

LERBSCHER Jean-Pierre wrote:



Hi,
I have the same problem, do you have a solution ?
Thanks
Jean-pierre




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to