[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.technology.memory-analyzer] Re: Classes from rt.jar loaded by different loaders ?
|
Andreas,
You may be right that different class loaders might reference the same
classes but I just tried to convince myself on this. Can someone tell me
when can a non-system classloader refer to a system class ? For example, I
tried to run these 2 examples and take a heap dump while the thread is
sleeping but I do not see TestCL referring to java.net.ServerSocket or
java.util.concurrent.ConcurrentLinkedQueue:
//example1
import java.net.*;
import java.util.concurrent.*;
import java.util.*;
public class TestCL extends java.lang.ClassLoader {
public static void main(String[] args) {
TestCL loader = new TestCL();
loader.load();
}
public void load() {
try {
String s = new String("satish");
Vector v = new Vector(10);
ServerSocket ss = new ServerSocket();
ConcurrentLinkedQueue list = new ConcurrentLinkedQueue();
System.out.println("TestCL...");
Thread.sleep(100000000);
} catch (Exception e) {
e.printStackTrace();
}
}
}
//example2
import java.net.*;
import java.util.concurrent.*;
import java.util.*;
public class TestCL extends java.lang.ClassLoader {
public static void main(String[] args) {
TestCL loader = new TestCL();
Thread t = new Thread(
new Runnable() {
public void run() {
try {
String s = new String("satish");
Vector v = new Vector(10);
ServerSocket ss = new ServerSocket();
ConcurrentLinkedQueue list = new ConcurrentLinkedQueue();
System.out.println("TestCL executed!!");
Thread.sleep(100000000);
} catch (Exception e) {
e.printStackTrace();
}
}
}, "TestThread");
t.setContextClassLoader(loader);
t.start();
try {
t.join();
} catch (Exception e) {
e.printStackTrace();
}
}
}