Package org.htmlunit.corejs.javascript
Class NativeJavaMethod
- java.lang.Object
-
- org.htmlunit.corejs.javascript.ScriptableObject
-
- org.htmlunit.corejs.javascript.IdScriptableObject
-
- org.htmlunit.corejs.javascript.BaseFunction
-
- org.htmlunit.corejs.javascript.NativeJavaMethod
-
- All Implemented Interfaces:
java.io.Serializable,Callable,ConstProperties,Constructable,DebuggableObject,Function,IdFunctionCall,Scriptable,SymbolScriptable
- Direct Known Subclasses:
FieldAndMethods
public class NativeJavaMethod extends BaseFunction
This class reflects Java methods into the JavaScript environment and handles overloading of methods.- See Also:
NativeJavaArray,NativeJavaPackage,NativeJavaClass, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.htmlunit.corejs.javascript.ScriptableObject
ScriptableObject.KeyComparator
-
-
Field Summary
Fields Modifier and Type Field Description private static booleandebugprivate java.lang.StringfunctionName(package private) MemberBox[]methodsprivate java.util.concurrent.CopyOnWriteArrayList<ResolvedOverload>overloadCacheprivate static intPREFERENCE_AMBIGUOUSNo clear "easy" conversionprivate static intPREFERENCE_EQUALTypes are equalprivate static intPREFERENCE_FIRST_ARGprivate static intPREFERENCE_SECOND_ARGprivate static longserialVersionUID-
Fields inherited from class org.htmlunit.corejs.javascript.BaseFunction
GENERATOR_FUNCTION_CLASS, Id_arguments, Id_arity, Id_length, Id_name, Id_prototype, MAX_INSTANCE_ID
-
Fields inherited from class org.htmlunit.corejs.javascript.ScriptableObject
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST
-
Fields inherited from interface org.htmlunit.corejs.javascript.Scriptable
NOT_FOUND
-
-
Constructor Summary
Constructors Constructor Description NativeJavaMethod(java.lang.reflect.Method method, java.lang.String name)NativeJavaMethod(MemberBox[] methods)NativeJavaMethod(MemberBox[] methods, java.lang.String name)NativeJavaMethod(MemberBox method, java.lang.String name)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectcall(Context cx, Scriptable scope, Scriptable thisObj, java.lang.Object[] args)Should be overridden.(package private) java.lang.Stringdecompile(int indent, int flags)Decompile the source information associated with this js function/script back into a string.(package private) intfindCachedFunction(Context cx, java.lang.Object[] args)(package private) static intfindFunction(Context cx, MemberBox[] methodsOrCtors, java.lang.Object[] args)Find the index of the correct function to call given the set of methods or constructors and the arguments.java.lang.StringgetFunctionName()private static intpreferSignature(java.lang.Object[] args, java.lang.Class<?>[] sig1, boolean vararg1, java.lang.Class<?>[] sig2, boolean vararg2)Determine which of two signatures is the closer fit.private static voidprintDebug(java.lang.String msg, MemberBox member, java.lang.Object[] args)(package private) static java.lang.StringscriptSignature(java.lang.Object[] values)java.lang.StringtoString()-
Methods inherited from class org.htmlunit.corejs.javascript.BaseFunction
construct, createObject, execIdCall, fillConstructorProperties, findInstanceIdInfo, findPrototypeId, getArity, getClassName, getClassPrototype, getInstanceIdName, getInstanceIdValue, getLength, getMaxInstanceId, getPrototypeProperty, getTypeOf, hasInstance, hasPrototypeProperty, init, init, initAsGeneratorFunction, initPrototypeId, isApply, isApplyOrCall, isGeneratorFunction, setImmunePrototypeProperty, setInstanceIdAttributes, setInstanceIdValue, setPrototypeProperty, setPrototypePropertyAttributes, setStandardPropertyAttributes, setupDefaultPrototype
-
Methods inherited from class org.htmlunit.corejs.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.htmlunit.corejs.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, defineProperty, delete, deleteProperty, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureSymbolScriptable, equivalentValues, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getBase, getBase, 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, putImpl, 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.htmlunit.corejs.javascript.Scriptable
delete, delete, get, get, getDefaultValue, getIds, getParentScope, getPrototype, has, has, put, put, setParentScope, setPrototype
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
PREFERENCE_EQUAL
private static final int PREFERENCE_EQUAL
Types are equal- See Also:
- Constant Field Values
-
PREFERENCE_FIRST_ARG
private static final int PREFERENCE_FIRST_ARG
- See Also:
- Constant Field Values
-
PREFERENCE_SECOND_ARG
private static final int PREFERENCE_SECOND_ARG
- See Also:
- Constant Field Values
-
PREFERENCE_AMBIGUOUS
private static final int PREFERENCE_AMBIGUOUS
No clear "easy" conversion- See Also:
- Constant Field Values
-
debug
private static final boolean debug
- See Also:
- Constant Field Values
-
methods
MemberBox[] methods
-
functionName
private java.lang.String functionName
-
overloadCache
private final transient java.util.concurrent.CopyOnWriteArrayList<ResolvedOverload> overloadCache
-
-
Constructor Detail
-
NativeJavaMethod
NativeJavaMethod(MemberBox[] methods)
-
NativeJavaMethod
NativeJavaMethod(MemberBox[] methods, java.lang.String name)
-
NativeJavaMethod
NativeJavaMethod(MemberBox method, java.lang.String name)
-
NativeJavaMethod
public NativeJavaMethod(java.lang.reflect.Method method, java.lang.String name)
-
-
Method Detail
-
getFunctionName
public java.lang.String getFunctionName()
- Overrides:
getFunctionNamein classBaseFunction
-
scriptSignature
static java.lang.String scriptSignature(java.lang.Object[] values)
-
decompile
java.lang.String decompile(int indent, int flags)Description copied from class:BaseFunctionDecompile the source information associated with this js function/script back into a string.- Overrides:
decompilein classBaseFunction- Parameters:
indent- How much to indent the decompiled result.flags- Flags specifying format of decompilation output.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
call
public java.lang.Object call(Context cx, Scriptable scope, Scriptable thisObj, java.lang.Object[] args)
Description copied from class:BaseFunctionShould be overridden.- Specified by:
callin interfaceCallable- Specified by:
callin interfaceFunction- Overrides:
callin 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 JavaScriptthisobjectargs- the array of arguments- Returns:
- the result of the call
-
findCachedFunction
int findCachedFunction(Context cx, java.lang.Object[] args)
-
findFunction
static int findFunction(Context cx, MemberBox[] methodsOrCtors, java.lang.Object[] args)
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(java.lang.Object[] args, java.lang.Class<?>[] sig1, boolean vararg1, java.lang.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
private static void printDebug(java.lang.String msg, MemberBox member, java.lang.Object[] args)
-
-