Please consider adding the isScriptObject(), isJavaObject() and isJavaFunction() functions as API (NativeJava? ScriptUtils?). There does not appear to be an efficient way to implement them in JS without using internal types, e.g.: var ScriptObject = Java.type('jdk.nashorn.internal.runtime.ScriptObject'); var isScriptObject = function(obj) { return obj instanceof ScriptObject; }; var isJavaObject = function(obj) { return Java.isType(obj.class) || !isScriptObject(obj); }; var isJavaFunction = function(fn) { return typeof fn === 'function' && isJavaObject(fn); };
|