I can input "java HelloWorld -verbose" to see which classes are loaded by jvm.
But I want to know more.
For example, for the HelloWorld program java.io.File will be loaded. I want to know why java.io.File be loaded, which class will let jvm load java.io.File.
How to do this?
Thanks
I'm not sure if the -Xdepend flag still exists. This article shows how to extract static dependencies using BCEL (ASM can do the same thing). I'm not sure what could be used at runtime, although it might be easy enough to tweak a classloader.
Ulf Dittmer wrote:Any I/O code will probably use one of the static fields of the File class, like.separator and such.
yeah,But the class java.io.File is just a example. There are many other classes which i don't know when and why be loaded.
jing hu
Ranch Hand
Joined: Jun 30, 2009
Posts: 63
posted
0
This article shows how to extract static dependencies using BCEL (ASM can do the same thing).
Now , I use ASM to trace the classes dependency. But I find there are some classes which i don't get when using ASM to trace classes dependency. So I want to know these classes which I don't get why are loaded and which classes depend these classes. So ASM will not be my choice.
although it might be easy enough to tweak a classloader
Can you tell how to do this. I am not family with the classloader.
You can use Jconsole to view the runtime information of any java application
you might have to keep the application running though
you can do the following
1. start the application and keep it running
2. start jconsole, which is present in the bin directory of the jdk installation
3. select your application from the menu
I am not sure if it shows all the classes that are loaded but its worth a try
Gaurav
jing hu
Ranch Hand
Joined: Jun 30, 2009
Posts: 63
posted
0
I need to trace the class dependency in the runtime, not find all classes. using the argument "-verbose", it can return all classes loaded by jvm.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.