For the project, we need a way to run custom scripts that can come with attached JAR files with additional classes.
What are my options when I want to write a couple of tests to make sure that a normal script leaves nothing behind?
I especially need to know: are all classes from attached JARs "offloaded"?
Note. I'm not looking for a 100% super waterproof solution that works in all versions of Java from 1.0 to 7. Right now, I just need to be better than βI have no ideaβ.
, - , ( ).
, , , " ". , . , , . , , , .
, pure-Java, OSGi . OSGi .
unit test . JVM -XX: -TraceClassUnloading , .
, , .
WeakReference ClassLoader, JAR, script, System.gc() assertNull(reference.get())
WeakReference
ClassLoader
System.gc()
assertNull(reference.get())
. ?
Java . ClassLoader , . , ClassLoader, ( ), ( ) GC, .
, , - . API, . , ClassLoader.
I see no way to fully automate testing for this. But I suppose you could track class unloading with any decent profiler.