Oql In Visualvm V1.4.4 - Get A Class's Field Names
I would like to execute an OQL query in VisualVM (v1.4.4) to retrieve the (non-static) field names for an object. The OQL documentation describes heap.findClass(className). This r
Solution 1:
You need to use map() function. The following OQL retrieves the field names of ByteArrayInputStream
class:
select map(heap.findClass('java.io.ByteArrayInputStream').fields, 'it.name')
Solution 2:
Just to add to the very helpful answer from @Tomas - which I have accepted.
Based on his insight, I can also now do things like this in OQL - using a callback instead of an expression string:
map(heap.findClass('java.io.ByteArrayInputStream').fields, function (it) {
var res = '';
res += toHtml(it.name) + " : " + toHtml(it.signature);
return res + "<br>";
});
The above example is trivial, but it opens up more possibilities.
His answer also made me realize where I was going wrong: OQL uses JavaScript expression language - not the exactly the same as JavaScript.
Post a Comment for "Oql In Visualvm V1.4.4 - Get A Class's Field Names"