1.java -verbose:class
在程序运行的时候有多少类被加载!你可以用verbose:class来监视,在命令行输入java -verbose:class XXX (XXX为程序名)你会在控制台看到加载的类的情况。verbose和verbose:class含义相同,输出虚拟机装入的类的信息,显示的信息大概格式如下:
[Opened D:\software\jdk1.6.0_21\jre\lib\rt.jar][Loaded java.lang.Object from D:\software\jdk1.6.0_21\jre\lib\rt.jar]...[Loaded java.lang.ThreadGroup from D:\software\jdk1.6.0_21\jre\lib\rt.jar][Loaded java.util.Map from D:\software\jdk1.6.0_21\jre\lib\rt.jar] //程序加载[Loaded java.util.Dictionary from D:\software\jdk1.6.0_21\jre\lib\rt.jar]...[Loaded java.lang.ref.ReferenceQueue$Lock from D:\software\jdk1.6.0_21\jre\lib\rt.jar][Loaded java.util.HashMap from D:\software\jdk1.6.0_21\jre\lib\rt.jar] //程序加载[Loaded java.util.Map$Entry from D:\software\jdk1.6.0_21\jre\lib\rt.jar][Loaded java.util.HashMap$Entry from D:\software\jdk1.6.0_21\jre\lib\rt.jar] //程序加载[Loaded java.security.AccessController from D:\software\jdk1.6.0_21\jre\lib\rt.jar]...[Loaded java.util.List from D:\software\jdk1.6.0_21\jre\lib\rt.jar] //程序加载...[Loaded java.util.Collections from D:\software\jdk1.6.0_21\jre\lib\rt.jar] //程序加载[Loaded java.util.Collections$EmptySet from D:\software\jdk1.6.0_21\jre\lib\rt.jar] //程序加载[Loaded java.util.Collections$EmptyList from D:\software\jdk1.6.0_21\jre\lib\rt.jar] //程序加载[Loaded java.util.Collections$EmptyMap from D:\software\jdk1.6.0_21\jre\lib\rt.jar] //程序加载[Loaded java.util.Collections$ReverseComparator from D:\software\jdk1.6.0_21\jre\lib\rt.jar] //程序加载...[Loaded java.util.ArrayList from D:\software\jdk1.6.0_21\jre\lib\rt.jar] //程序加载...[Loaded cn.com.sinosoft.iecs.web.util.UrlSignUtil from file:/D:/SVN/dev/%e7%bd%91%e9%94%80/iecs-online-web/target/classes/][Loaded java.io.UnsupportedEncodingException from D:\software\jdk1.6.0_21\jre\lib\rt.jar] //程序加载[Loaded java.security.NoSuchAlgorithmException from D:\software\jdk1.6.0_21\jre\lib\rt.jar] //程序加载[Loaded cn.com.sinosoft.iecs.online.core.util.PropertiesUtil from file:/D:/SVN/dev/%e7%bd%91%e9%94%80/iecs-online-core/target/classes/]...[Loaded java.security.MessageDigestSpi from D:\software\jdk1.6.0_21\jre\lib\rt.jar] //程序加载...[Loaded sun.security.provider.ByteArrayAccess from D:\software\jdk1.6.0_21\jre\lib\rt.jar]ea542da6768faa749dbc08ea51d746c5 //执行结果[Loaded java.util.IdentityHashMap$KeySet from D:\software\jdk1.6.0_21\jre\lib\rt.jar][Loaded java.util.IdentityHashMap$IdentityHashMapIterator from D:\software\jdk1.6.0_21\jre\lib\rt.jar][Loaded java.util.IdentityHashMap$KeyIterator from D:\software\jdk1.6.0_21\jre\lib\rt.jar]
当虚拟机报告类找不到或类冲突时可用此参数来诊断来查看虚拟机从装入类的情况。
2.java –verbose:gc
。。。
[Loaded sun.security.provider.ByteArrayAccess from D:\software\jdk1.6.0_21\jre\lib\rt.jar]
[Full GC 812K->442K(15872K), 0.0031244 secs]
ea542da6768faa749dbc08ea51d746c5 //执行结果[Loaded sun.misc.Cleaner from C:\Java\jdk7\jre\lib\rt.jar]
3.java –verbose:jni
-verbose:jni输出native方法调用的相关情况,一般用于诊断jni调用错误信息。
在虚拟机调用native方法时输出设备显示信息,格式如下:
[Dynamic-linking native method.lang.Object.registerNatives ... JNI]
该参数用来监视虚拟机调用本地方法的情况,在发生jni错误时可为诊断提供便利。
具体测试方法: