Java Tools Tutorials - Herong's Tutorial Notes - Version 5.32, by Dr. Herong Yang
Object Query Language (OQL)
This section describes what is OQL (Object Query Language). OQL statement syntax and examples are also provided.
OQL query is of the form"
where class name is fully qualified Java class name (example: java.net.URL) or array class name. [C is char array name, [Ljava.io.File; is name of java.io.File and so on. Note that fully qualified class name does not always uniquely identify a Java class at runtime. There may be more than one Java class with the same name but loaded by different loaders. So, class name is permitted to be id string of the class object. If instanceof keyword is used, subtype objects are selected. If this keyword is not specified, only the instances of exact class specified are selected. Both from and where clauses are optional.
select all Strings of length 100 or more: select s from java.lang.String s where s.count >= 100 select all int arrays of length 256 or more: select a from [I a where a.length >= 256 show content of Strings that match a regular expression: select s.value.toString() from java.lang.String s where /java/(s.value.toString()) show path value of all File objects: select file.path.value.toString() from java.io.File file show names of all ClassLoader classes: select classof(cl).name from instanceof java.lang.ClassLoader cl show instances of the Class identified by given id string: select o from instanceof 0xd404b198 o Note that 0xd404b198 is id of a Class (in a session). This is found by looking at the id shown in that class's page.
See next section on how to run OQL statements on the "jhat" Web server.
Last update: 2015.
Table of Contents