Java Tools Tutorials - Herong's Tutorial Notes - Version 5.32, 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:
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 != null && classof(i).name == '[Ljava.lang.String;'
Last update: 2015.
Table of Contents