Yep, I caught the 'defineClass' error as I was implementing your other fix.
I thought I was
checking that all the bytes had been read by checking entry.getSize(), but
clearly I
was confused.

Thanks a lot!

--dave



                                                                                       
                       
                    [EMAIL PROTECTED]                                                     
                       
                    om                   To:     "Ant Users List" 
<[EMAIL PROTECTED]>               
                                         cc:                                           
                       
                    01/17/2002           Subject:     Re: Invoking ant with custom 
ClassLoader                
                    08:57 AM                                                           
                       
                    Please respond                                                     
                       
                    to "Ant Users                                                      
                       
                    List"                                                              
                       
                                                                                       
                       
                                                                                       
                       




Your problem is not reading the jarEntry fully and thus submitting
incomplete .class content to defineClass(). Log the result of
jarStream.read(classBytes) and you will see. If you replace that line with
something like

                          for (int read = 0, totalread = 0;
                                (read = jarStream.read(classBytes,
totalread, classBytes.length - totalread)) != -1;
                                totalread += read);

your issue goes away. As some programmers, you assume that
InputStream.read (byte []) will read the entire array. It is typical for
disk file-based streams but is not guaranteed to be the case in general.

Vlad.



Please respond to "Ant Users List" <[EMAIL PROTECTED]>
To:     [EMAIL PROTECTED]
cc:

Subject:        Invoking ant with custom ClassLoader



We have multiple development environments, each running a different
release
level of the ANT engine.

I am trying to write a single "gateway" interface which will read info
from
a .properties file, determine the correct ANT release level for the build,
and fire it off.  I therefore need to launch ANT using a custom
ClassLoader.

The problem is, my custom ClassLoader cannot load
org.apache.tools.ant.Project.  I get a java.lang.ClassFormatError and a
message about "Illegal constant pool type".

I'm attaching a test program.  Compile it in some working directory,
and drop a copy of ant.jar into that directory (I used ant 1.4).  Then
do the following:

1) 'set CLASSPATH=.;ant.jar'
2) 'java Test2'

No error.  But

3) 'set CLASSPATH=.'
4) 'java Test2'

and you'll see the error.  I'm running on Windows 2000.  I
encounter this problem both with jdk1.3.1 and jdk1.3.1_01.

Any insights would be greatly appreciated.

Thanks!

--dave

(See attached file: Test2.java)

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




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






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

Reply via email to