Package org.mozilla.javascript
Class NativeJavaMethod
java.lang.Object
org.mozilla.javascript.ScriptableObject
org.mozilla.javascript.IdScriptableObject
org.mozilla.javascript.BaseFunction
org.mozilla.javascript.NativeJavaMethod
- All Implemented Interfaces:
Serializable
,Callable
,ConstProperties
,Constructable
,DebuggableObject
,Function
,IdFunctionCall
,Scriptable
,SymbolScriptable
- Direct Known Subclasses:
FieldAndMethods
This class reflects Java methods into the JavaScript environment and handles overloading of
methods.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.mozilla.javascript.ScriptableObject
ScriptableObject.KeyComparator
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final boolean
private String
(package private) MemberBox[]
private final CopyOnWriteArrayList
<ResolvedOverload> private static final int
No clear "easy" conversionprivate static final int
Types are equalprivate static final int
private static final int
private static final long
Fields inherited from class org.mozilla.javascript.BaseFunction
GENERATOR_FUNCTION_CLASS
Fields inherited from class org.mozilla.javascript.ScriptableObject
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST
Fields inherited from interface org.mozilla.javascript.Scriptable
NOT_FOUND
-
Constructor Summary
ConstructorsConstructorDescriptionNativeJavaMethod
(Method method, String name) NativeJavaMethod
(MemberBox[] methods) NativeJavaMethod
(MemberBox[] methods, String name) NativeJavaMethod
(MemberBox method, String name) -
Method Summary
Modifier and TypeMethodDescriptioncall
(Context cx, Scriptable scope, Scriptable thisObj, Object[] args) Should be overridden.(package private) String
decompile
(int indent, int flags) Decompile the source information associated with this js function/script back into a string.(package private) int
findCachedFunction
(Context cx, Object[] args) (package private) static int
findFunction
(Context cx, MemberBox[] methodsOrCtors, Object[] args) Find the index of the correct function to call given the set of methods or constructors and the arguments.private static int
preferSignature
(Object[] args, Class<?>[] sig1, boolean vararg1, Class<?>[] sig2, boolean vararg2) Determine which of two signatures is the closer fit.private static void
printDebug
(String msg, MemberBox member, Object[] args) (package private) static String
scriptSignature
(Object[] values) toString()
Methods inherited from class org.mozilla.javascript.BaseFunction
construct, createObject, execIdCall, fillConstructorProperties, findInstanceIdInfo, findPrototypeId, getArity, getClassName, getClassPrototype, getInstanceIdName, getInstanceIdValue, getLength, getMaxInstanceId, getPrototypeProperty, getTypeOf, hasInstance, hasPrototypeProperty, init, initAsGeneratorFunction, initPrototypeId, isApply, isApplyOrCall, isGeneratorFunction, setImmunePrototypeProperty, setInstanceIdAttributes, setInstanceIdValue, setPrototypeProperty, setPrototypePropertyAttributes, setStandardPropertyAttributes, setupDefaultPrototype
Methods inherited from class org.mozilla.javascript.IdScriptableObject
activatePrototypeMap, addIdFunctionProperty, defaultGet, defaultHas, defaultPut, defineOwnProperty, delete, delete, ensureType, exportAsJSClass, findInstanceIdInfo, findPrototypeId, get, get, getAttributes, getAttributes, getIds, getOwnPropertyDescriptor, has, has, hasPrototypeMap, initPrototypeConstructor, initPrototypeMethod, initPrototypeMethod, initPrototypeMethod, initPrototypeValue, initPrototypeValue, instanceIdInfo, put, put, setAttributes
Methods inherited from class org.mozilla.javascript.ScriptableObject
addLazilyInitializedValue, applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildClassCtor, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, checkValidAttributes, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureSymbolScriptable, equivalentValues, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, getIds, getObjectPrototype, getParentScope, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, has, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, putConst, putConstProperty, putProperty, putProperty, putProperty, querySlot, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setCommonDescriptorProperties, setExternalArrayData, setGetterOrSetter, setParentScope, setPrototype, size
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.mozilla.javascript.Scriptable
delete, delete, get, get, getDefaultValue, getIds, getParentScope, getPrototype, has, has, put, put, setParentScope, setPrototype
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
PREFERENCE_EQUAL
private static final int PREFERENCE_EQUALTypes are equal- See Also:
-
PREFERENCE_FIRST_ARG
private static final int PREFERENCE_FIRST_ARG- See Also:
-
PREFERENCE_SECOND_ARG
private static final int PREFERENCE_SECOND_ARG- See Also:
-
PREFERENCE_AMBIGUOUS
private static final int PREFERENCE_AMBIGUOUSNo clear "easy" conversion- See Also:
-
debug
private static final boolean debug- See Also:
-
methods
MemberBox[] methods -
functionName
-
overloadCache
-
-
Constructor Details
-
NativeJavaMethod
NativeJavaMethod(MemberBox[] methods) -
NativeJavaMethod
-
NativeJavaMethod
-
NativeJavaMethod
-
-
Method Details
-
getFunctionName
- Overrides:
getFunctionName
in classBaseFunction
-
scriptSignature
-
decompile
Description copied from class:BaseFunction
Decompile the source information associated with this js function/script back into a string.- Overrides:
decompile
in classBaseFunction
- Parameters:
indent
- How much to indent the decompiled result.flags
- Flags specifying format of decompilation output.
-
toString
-
call
Description copied from class:BaseFunction
Should be overridden.- Specified by:
call
in interfaceCallable
- Specified by:
call
in interfaceFunction
- Overrides:
call
in classBaseFunction
- Parameters:
cx
- the current Context for this threadscope
- the scope to execute the function relative to. This is set to the value returned by getParentScope() except when the function is called from a closure.thisObj
- the JavaScriptthis
objectargs
- the array of arguments- Returns:
- the result of the call
-
findCachedFunction
-
findFunction
Find the index of the correct function to call given the set of methods or constructors and the arguments. If no function can be found to call, return -1. -
preferSignature
private static int preferSignature(Object[] args, Class<?>[] sig1, boolean vararg1, Class<?>[] sig2, boolean vararg2) Determine which of two signatures is the closer fit. Returns one of PREFERENCE_EQUAL, PREFERENCE_FIRST_ARG, PREFERENCE_SECOND_ARG, or PREFERENCE_AMBIGUOUS. -
printDebug
-