ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Keith Hatton" <>
Subject RE: [OT] Re: unit test failure w/junit task
Date Thu, 06 Mar 2003 13:30:41 GMT
Hi Erik,

Unfortunately, I've deleted the beginning of this thread. But I seem to remember that it might
have something to do with classloaders.

Normally, you (i.e. in this case, your 3rd party lib) would load native code in a static {}
block so that it only happens once during the lifetime of the VM.

However, if different classloaders come into play, the same class can be loaded multiple times,
so the static {} block gets executed multiple times. I'm getting out of my depth at this point
but I presume native code is unaware of the JVM classloader separation and that's where things
are going awry.

I would have expected that <junit fork="true" .../> would solve any issues though. Suggest
you check your classpath thoroughly. My best guess is that somehow two classloaders are being
asked to load the class that loads the DLL. This might actually be to do with JUnit rather
than Ant as it monkeys around with the classloaders too - can you run your JUnit class through
the JUnit GUI/command line interface, outside of Ant, to see what happens?

Hope this helps

-----Original Message-----
From: Erik Price []
Sent: 06 March 2003 13:18
To: Ant Users List
Subject: [OT] Re: unit test failure w/junit task

Keith Hatton wrote:
> Thing is, if it uses JNI, there is no way to *unload* the native code programatically.

Well, what I'm not entirely clear on (and sorry this is going OT) is why 
the JNI library (the dll) is getting loaded more than once in the first 
place.  My understanding is that a class is loaded when it is needed and 
then kept around if it is needed again.  But, that may be incorrect, and 
the rules for native libraries may be different (I haven't used them 


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message