Say you have a class:
abstract class PrintStuff {
public static void print() throws InterruptedException {
while (true) {
System.out.println("Hello");
Thread.sleep(1000);
}
}
}
And then you create a classloader that loads this class, and then
through
reflection, invokes the print() method. No other class is loaded by
that classloader.
Will the fact that a thread is running in a static method of a class
mean that the class is reachable, and therefore the classloader is
reachable
as well?
Obviously (we think), if there are any active uses of an instance of a
class X,
then the class is reachable.
But we couldn't absolutely convince ourselves that running a static
method
of a class ensures the class is reachable.
(By the way, section 12.7 of the JLS (2nd edition) says "A class or
interface may
be unloaded if and only if its defining class loader may be reclaimed
by the
garbage collector as discussed in §12.6." But it isn't discussed there.
Bill
-------------------------------
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel
This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:01:07 EDT