Java Tools Tutorials - Herong's Tutorial Notes - Version 5.30, by Dr. 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.

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:
jhat - Object Query Language (OQL)

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

 About This Book

 Java Tools Terminology

 Installing Java 8 on Windows

 'javac' - The Java Program Compiler

 'java' - The Java Program Launcher

 'jdb' - The Java Debugger

 'jconsole' - Java Monitoring and Management Console

 'jstat' - JVM Statistics Monitoring Tool

JVM Troubleshooting Tools

 JVM Troubleshooting Tools in JDK 1.5

 'jinfo' - VM Option Value Checker

 Changing HotSpot VM Option using 'jinfo'

 'jstack' - Stack Tracer of JVM Threads

 Java Thread Deadlock Demo Program

 Detecting Java Thread Deadlocks with 'jstack'

 'jmap' - JVM Heap Dump Tool

 Printing Histogram of Java Object Heap

 Generating Heap Dump File with 'jmap'

 'jhat' - Java Heap Analysis Tool

 Starting 'jhat' Web Server on a Heap Dump File

 Listing Instance Counts of All Classes

 Browsing Object Instance Values

 Object Query Language (OQL)

Searching for Instances with OQL Statements

 jvisualvm (Java VisualVM) - JVM Visual Tool

 'jar' - The JAR File Tool

 'javap' - The Java Class File Disassembler

 'keytool' - Public Key Certificate Tool

 'native2ascii' - Native-to-ASCII Encoding Converter

 Outdated Tutorials

 References

 PDF Printing Version

Searching for Instances with OQL Statements - Updated in 2014, by Dr. Herong Yang