JVM "-verbose:class" Option

This section provides a tutorial example on how to the '-verbose:class' option on the 'java' command to see when and where classes are loaded into the JVM.

If you want to know when and where classes are loaded into the JVM, you can use the "-verbose:class" option on the "java" command.

Let's try it without launching any Java application on JDK 10 HotSpot JVM:

C:\herong>\progra~1\java\jdk-10.0.1\bin\java -version -verbose:class

[0.008s][info][class,load] opened: 
   C:\Program Files\Java\jre-10.0.1\lib\modules
[0.048s][info][class,load] java.lang.Object source: jrt:/java.base
[0.049s][info][class,load] java.io.Serializable source: jrt:/java.base
[0.049s][info][class,load] java.lang.Comparable source: jrt:/java.base
[0.049s][info][class,load] 
   java.lang.CharSequence source: jrt:/java.base
[0.049s][info][class,load] java.lang.String source: jrt:/java.base
... 417 lines omitted ...
[0.206s][info][class,load] 
   java.nio.charset.CoderResult$Cache source: jrt:/java.base
[0.206s][info][class,load] 
   java.nio.charset.CoderResult$1 source: jrt:/java.base
[0.207s][info][class,load] 
   java.nio.charset.CoderResult$2 source: jrt:/java.base
[0.210s][info][class,load] java.lang.Shutdown source: jrt:/java.base
[0.211s][info][class,load] 
   java.lang.Shutdown$Lock source: jrt:/java.base

The output is very interesting. It shows that the JVM loaded 427 classes to just print the version information.

Now try -verbose:class with a simple Java application:

C:\herong>\progra~1\java\jdk-10.0.1\bin\java -verbose:class Hello

[0.009s][info][class,load] 
   opened: C:\Program Files\Java\jre-10.0.1\lib\modules
[0.041s][info][class,load] java.lang.Object source: jrt:/java.base
[0.041s][info][class,load] java.io.Serializable source: jrt:/java.base
[0.041s][info][class,load] java.lang.Comparable source: jrt:/java.base
[0.041s][info][class,load] 
   java.lang.CharSequence source: jrt:/java.base
[0.042s][info][class,load] java.lang.String source: jrt:/java.base
...
[0.150s][info][class,load] 
   sun.security.util.Debug source: jrt:/java.base
[0.151s][info][class,load] Hello source: file:/C:/herong/
,..
Hello world!
...

Comparing with JDK previous versions, HotSpot JVM has changed the output format. It also seems to be no longer using the "shared object file". Hers is the result from JDK JDK 1.7:

C:\herong>\progra~1\Java\jdk1.7.0_45\bin\java -verbose:class -version

[Loaded java.lang.Object from shared objects file]
[Loaded java.io.Serializable from shared objects file]
[Loaded java.lang.Comparable from shared objects file]
[Loaded java.lang.CharSequence from shared objects file]
[Loaded java.lang.String from shared objects file]
... 309 lines deleted ...
[Loaded sun.misc.URLClassPath from shared objects file]
[Loaded sun.net.www.protocol.jar.Handler from shared objects file]
[Loaded sun.misc.Launcher$AppClassLoader from shared objects file]
[Loaded sun.misc.Launcher$AppClassLoader$1 from shared objects file]
[Loaded java.lang.SystemClassLoaderAction from shared objects file]
[Loaded java.lang.Shutdown from shared objects file]
[Loaded java.lang.Shutdown$Lock from shared objects file]

Last update: 2018.

Table of Contents

 About This Book

 JVM (Java Virtual Machine) Specification

 Java HotSpot VM - JVM by Oracle/Sun

 java.lang.Runtime Class - The JVM Instance

 java.lang.System Class - The Operating System

ClassLoader Class - Class Loaders

 What Is Class Loader

 What Is java.lang.ClassLoader Class

 Accessing the ClassLoader of a Class

JVM "-verbose:class" Option

 loadClass() Method - Loading Classes Explicitly

 getSystemResource() Method - Finding Files

 Class Loading Problem - JAR Hell

 ClassChecker.java - Reports Class Loader

 ClassChecker.java - Reports Class Locations

 "superclass access check failed" Class Load Error

 Class Loading Followed by Class Initialization

 Class Class - Class Reflections

 JVM Runtime Data Areas

 JVM Stack, Frame and Stack Overflow

 Thread Testing Program and Result

 CPU Impact of Multi-Thread Applications

 I/O Impact of Multi-Thread Applications

 CDS (Class Data Sharing)

 Micro Benchmark Runner and JVM Options

 Micro Benchmark Tests on "int" Operations

 Micro Benchmark Tests on "long" Operations

 Micro Benchmark Tests in JIT Compilation Mode

 Micro Benchmark Tests on "float" and "double" Operations

 JRockit JVM 28.2.7 by Oracle Corporation

 Outdated Tutorials

 References

 Full Version in PDF/EPUB