I am interested in knowing why visualvm OQL has a problem with the following statement:
select filter(heap.objects("java.util.HashMap"), isTrue(it));
function isTrue(object) {
return true;
}
Exception is:
javax.script.ScriptException: sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: "it" is not defined. (#1)
In contrast, visualvm OQL does not have a problem with any of the following examples:
Example 1 (note "it" is not quoted):
select filter(heap.objects("java.util.HashMap"),
function(it) {
return true;
});
Example 2 (note "it" is quoted):
select filter(heap.objects("java.util.HashMap"), isTrue("it"));
function isTrue(object) {
if (object instanceof String) {
throw "String passed!";
}
return true;
}
Example 3 ("function(it)" handled specially in OQL for some reason?):
select filter(heap.objects("java.util.HashMap"), function(it) { return isTrue(it); });
function isTrue(object) {
return true;
}
I ask this because it seems non-intuitive and variations of non-intuitive behavior show up unexpectedly and slow me down when I am trying to create something usable.