Java Tools Tutorials - Herong's Tutorial Examples - v6.23, by Herong Yang
Searching for Instances with OQL Statements
This section provides a tutorial example on how to write an OQL (Object Query Language) query statement to search for object instances with specific conditions.
Warning: "jhat" has been discontinued since JDK 9. But if you still have JDK 1.8 installed, you can continue to use it to browser heap dump files generated by JDK 9 to JDK 12.
To test the power of OQL, I want to find those Object[] instances created by my program, excluding Object[] created by the JVM platform.
1. Run a Web browser with http://localhost:7000. The heap dump first page shows up.
2. Click the link of "Execute Object Query Language (OQL) query". The OQL query page shows up.
3. Enter the following query and click the Execute button:
select i from [Ljava.lang.Object; i where i.length == 10
Cool. "jhat" returns a list of instances that matches my query condition:
But the previous OQL query is not good enough to return only Object[] instances I wanted. The query below will do a better job. Try it.
select i from [Ljava.lang.Object; i where i.length == 10 && i[5] != null && classof(i[5]).name == '[Ljava.lang.String;'
Watch out the OQL statement syntax. It takes JavaScript expressions only, not SQL expressions.
Table of Contents
javac - The Java Program Compiler
java - The Java Program Launcher
jpackage - Binary Package Builder
javadoc - The Java Document Generator
jdeps - The Java Class Dependency Analyzer
jdeprscan - The Java Deprecated API Scanner
jcmd - The JVM Diagnostic Tool
jconsole - Java Monitoring and Management Console
jstat - JVM Statistics Monitoring Tool
JVM Troubleshooting Tools in JDK
jinfo - VM Option Value Checker
jinfo - Changing HotSpot VM Option
jstack - Stack Tracer to Generate Thread Dump
Java Thread Deadlock Demo Program
jstack - Detecting Java Thread Deadlocks
Printing Histogram of Java Object Heap
jmap - Generating Heap Dump File
jhat - Java Heap Analysis Tool
jhat - Starting Web Server on a Heap Dump File
Listing Instance Counts of All Classes
Browsing Object Instance Values
►Searching for Instances with OQL Statements
jhsdb - The Java HotSpot Debugger
jvisualvm (Java VisualVM) - JVM Visual Tool
javap - The Java Class File Disassembler
keytool - Public Key Certificate Tool
jrunscript - Script Code Shell
native2ascii - Native-to-ASCII Encoding Converter