Hi,
I am coding a Taskdef that involve the following senario. After search
much for the solution, I'd like to suggest adding a Path getClassPath()
method to AntClassLoader.
My class uses BCEL which load the raw class files for analysis and
manipulation. I need this capacity because the class file will later be
written out to an archive and deploy on the handheld devices.
My source tree setup is:
Project ---+ src
+ build ---+ classes
+ lib ---+ all jars
The taskdef is include in one of the jars under the lib directory.
During the runtime, a class path is constructed from all jars under lib
and using in <available> to load the taskdef. So far so good.
However, during the execution of the taskdef, it calls BCEL to load
the raw class files which gets classpath from three system property:
java.class.path, sun.boot.class.path, and java.ext.dirs.
Now, here is the problem. The classpath setup by AntClassLoader isn't
visible to the BCEL classes which in turn can't load the raw class files
correctly.
I look all over for a way to get the classpath but couldn't and I
don't want to add classpath attribute to the taskdef itself. It's
confusing to the users.
I figure that adding a getClassPath to the AntClassLoader is the best
solution. The taskdef can check if it's loaded by the AntClassLoader and
set up the classpath according.
I'd like to know if there is any drawback implementing the method on
AntClassLoader. Does it break any encapsulation?
For the time being, I am adding classpath and classpathref to my
taskdef.
Thanks.
David Li
DigitalSesame