On Sat, Apr 14, 2001 at 05:54:37PM +0200, Michel CASABIANCA wrote:
> Using bsh 1.1 alpha 5, I have found a bug related to introspection.
> This sample source file reproduce it:
> // introspection test
> import *;
> // OK
> t=new Test();
> // crash
> The last line bugs with the following output:
> Error in file: bsh.TargetError: Sourced file: ./test.bsh:TargetError :
> Class .forName ( "Test" )
> Target exception: java.lang.ClassNotFoundException: Test
> I met this bug with all code using introspection (such as jdbc driver
> loading, jndi and so on).
Currently, in order to take advantage of the added classpath you will have to
load the class through one of the following mechanisms -
You can use the current namespace, which will take advantage of imports, etc:
t = this.namespace.getClass("Test");
or you can go straight to the BshClassManager with the absolute class name:
t = BshClassManager.classForName("mypackage.Test");
I will try to document this better. In the next release I plan to add a
bsh command called "getClass()" which will do the first technique above.
It's possible that in the future we might be able to intercept the standard
Class.forName mechanism and get it to do the right thing.