JDK-8049086 : Minor API convenience functions on "Java" object
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: jdk.nashorn
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2014-07-02
  • Updated: 2015-01-21
  • Resolved: 2014-07-04
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
8u40Fixed 9 b23Fixed
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);
(started doing this last night..)

This sounds like a really good idea. I'd use it. I thought ScriptFunction.isBuiltIn() was the pinnacle of technology so far. Thank you, Bryan!