Classloading issues...

Patrick Niemeyer <[email protected]> Sat, 14 May 2005 13:15:56 -0500
Newsgroups gmane.comp.java.beanshell.devel
Message-ID <[email protected]>
In order to complete BeanShell's class generation and classpath  
management integration with Java I'm considering doing the following  
things.  I'd be interested in any feedback:

1) Where allowed, BeanShell needs to set itself as the thread context  
classloader (delegating to any previous context classloader) during  
the span of an evaluation within the interpreter.

This will allow generated classes and added / reloaded classpath to  
be visible not only within the script but to any external Java apps  
and APIs that respect the context classloader and are called by the  
script.

2) Perhaps more controversially:  Within BeanShell scripts, the  
interpreter needs to intercept calls to Class.forName() and perform  
them relative to the BeanShell classloader.  I would expect this to  
be part of a more general hook to intercept/override any registered  
method or class.  (Another candidate would be ObjectInputStream).

I realize that there are many ways to get a class loaded (e.g. you  
could ask some random object for its class and get the classloader  
that way).  We can't really intercept them all.  But this seems to  
cover the most common case in a way that I believe the user would  
expect.  As a reminder, BeanShell has a getClass() command that does  
the right thing, but of course interpreting regular Java code we  
won't find that.

Let me know if you have thoughts.


Pat




-------------------------------------------------------
This SF.Net email is sponsored by Oracle Space Sweepstakes
Want to be the first software developer in space?
Enter now for the Oracle Space Sweepstakes!
http://ads.osdn.com/?ad_id=7393&alloc_id=16281&op=click