It looks like there is a bug in addClassPath when it is
used with jars.
In the attached code sample, I have defined a sequence
in which a series of bsh scripts is called recursively.
Each of these bsh scripts anonymously extends a dummy
I’ve included a good version of code that works, and a
bad version that is broken:
In the good version, there are no jar files involved,
and the classpath is not changed within the scripts.
The broken version is the same, except that the bsh
scripts add the jar containing the dummy class to the
classpath. A ClassCast exception occurs when the dummy
class within bean1 gets the instance of the dummy class
Note that to get this code to run, you must get
bsh-2.0b4.jar and put it the directory with the rest of
the files in good version and broken version, or have
it on your classpah. I'd have put it in myself but
there is an attachment size limit.
Files in good and/or broken versions:
BugRunner: main class for running the code
DummyClass: the class that is anonymously extended
within .bsh scripts
bean1.bsh: a script called by the BugRunner
bean2.bsh: a script that should be recursively called
through the run method of DummyClass within bean1.bsh
compile.bat: script to compile java files in GoodVersion
run.bat: script to run BugRunner within GoodVersion and
makejar.bat: script to compile java files and form a
jar containing DummyClass.class within BrokenVersion
Log in to post a comment.