When running a java program using the java command you can specify the verbose option with -verbose which allows you to inspect when classes are loaded. For example:
java -verbose Test | grep "file:"
[Loaded Test from file:/Users... ]
[Loaded C1 from file:/Users... ]
[Loaded A1 from file:/Users... ]
[Loaded B1 from file:/Users...]
[Loaded C2 from file:/Users...]
Is there a way to get an indication of when the verification stage happens? Verification of a class doesn’t necessarily follow directly after loading it. For example something like this would be ideal:
java -verbose Test | grep "file:"
[Loaded Test from file:/Users... ]
[Loaded C1 from file:/Users... ]
[Loaded A1 from file:/Users... ]
[Loaded B1 from file:/Users...]
[Verified C1]
[Loaded C2 from file:/Users...]
[Verified C2]
etc
To ward of those “You dont need this”, “Why would you want to do this” answers. Its just out of pure interest and is still worthy of a question.
As @Antimony suggested, to see when classes are verified one needs to modify the source of the JVM being used before recompiling.
Oracles HotSpot vm source already has numerous logging lines to indicate different stages of verification and they can be enabled by changing
to true in