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?
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.
Joined: Jun 30, 2009
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.