A concise tutorial on Object Query Language (OQL)
1. OQL syntax
The OQL syntax is as follows:
SELECT * FROM [ INSTANCEOF ] <class_name> [ WHERE <filter-expression>]2. Explanation of syntax clauses
The select clause
SELECT toString(x),
x.value,
x.@usedHeapSize,
toHex(x.@objectAddress),
outbounds(x)
FROM java.lang.Integer x The
toStringandoutboundsmethods are built-in methods:
toHex(num) | Displays the value in hexadecimal. |
toString(object) | Displays the string representation of the object. |
dominators(object) | Displays all objects immediately dominated by the object. |
outbounds(object) | Displays all objects referenced by the object. |
inbounds(object) | Display all referenced objects |
classof(object) | Displays the `java.lang.Class` of the object. |
dominatorof(object) | Displays the object that immediately dominates the object. |
x.valueaccesses a field of the object.x.@usedHeapSizeaccesses built-in properties of the object. Common properties are as follows:
x.@objectId | Object ID |
x.@objectAddress | Object address |
x.@class | The `java.lang.Class` representation of the object. |
x.@usedHeapSize | |
x.@retainedHeapSize | |
x.@classLoaderId | The ID of the object's class loader. This property is only available if x is a `java.lang.Class` object. |
x.@length | The length of the array. This property is only available if x is an array. |
For a complete list of properties, see the Eclipse documentation.
The from clause
The from clause specifies the data source. Common from data sources are as follows:
SELECT * FROM java.lang.Integer | Specifies objects of the java.lang.Integer class. |
SELECT * FROM INSTANCEOF java.util.AbstractCollection | Specifies objects that are instances of java.util.AbstractCollection. |
SELECT * FROM OBJECTS 0xcafebabe | Uses an object at a specific address as the data source. |
SELECT v, v.@length FROM OBJECTS ( SELECT OBJECTS s.value FROM java.lang.String s ) v | Uses the result of a subquery as the data source. |
The where clause
The where clause is used for data filtering. It supports the following symbols:
>=, <=, >, <, [ NOT ] LIKE, [ NOT ] IN, IMPLEMENTS