-
Type:
Enhancement
-
Resolution: Won't Fix
-
Priority:
P5
-
Affects Version/s: 6u10
-
Component/s: core-libs
-
x86
-
windows_vista
A DESCRIPTION OF THE REQUEST :
The class javax.script allows to get objects that exist in a script engine, e.g.
Object obj = engine.get("obj");
however, it does not allow the java program to tell what that object is.
E.g. the class of the object does not reveal if it is a variable or a function.
Consequently, the java program is unable to tell if it can invoke it or not.
JUSTIFICATION :
A java program must be able to tell what script objects are so as to use them
properly, or reject uses that are not allowed for them.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Have a method in class ScriptEngine of Invocable that tells whether a name denotes
an object in the script engine that is a function or not.
CUSTOMER SUBMITTED WORKAROUND :
There is no general workaround that can be used on every scripting engine.
Some workarounds exist for specific engines, but they are not portable on
other engines. E.g. with the default Rhino javascript engine, a java program
can ask the engine to evaluate "typeof(name)" and check that the evaluation
results in the string "function". This works only for javascript, and implies the
evaluation of an expression, which is quite expensive.
The class javax.script allows to get objects that exist in a script engine, e.g.
Object obj = engine.get("obj");
however, it does not allow the java program to tell what that object is.
E.g. the class of the object does not reveal if it is a variable or a function.
Consequently, the java program is unable to tell if it can invoke it or not.
JUSTIFICATION :
A java program must be able to tell what script objects are so as to use them
properly, or reject uses that are not allowed for them.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Have a method in class ScriptEngine of Invocable that tells whether a name denotes
an object in the script engine that is a function or not.
CUSTOMER SUBMITTED WORKAROUND :
There is no general workaround that can be used on every scripting engine.
Some workarounds exist for specific engines, but they are not portable on
other engines. E.g. with the default Rhino javascript engine, a java program
can ask the engine to evaluate "typeof(name)" and check that the evaluation
results in the string "function". This works only for javascript, and implies the
evaluation of an expression, which is quite expensive.