Class NativeJavaMethod

    • Field Detail

      • PREFERENCE_EQUAL

        private static final int PREFERENCE_EQUAL
        Types are equal
        See Also:
        Constant Field Values
      • PREFERENCE_AMBIGUOUS

        private static final int PREFERENCE_AMBIGUOUS
        No clear "easy" conversion
        See Also:
        Constant Field Values
      • 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

      • scriptSignature

        static java.lang.String scriptSignature​(java.lang.Object[] values)
      • decompile

        java.lang.String decompile​(int indent,
                                   int flags)
        Description copied from class: BaseFunction
        Decompile the source information associated with this js function/script back into a string.
        Overrides:
        decompile in class BaseFunction
        Parameters:
        indent - How much to indent the decompiled result.
        flags - Flags specifying format of decompilation output.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • call

        public java.lang.Object call​(Context cx,
                                     Scriptable scope,
                                     Scriptable thisObj,
                                     java.lang.Object[] args)
        Description copied from class: BaseFunction
        Should be overridden.
        Specified by:
        call in interface Callable
        Specified by:
        call in interface Function
        Overrides:
        call in class BaseFunction
        Parameters:
        cx - the current Context for this thread
        scope - 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 JavaScript this object
        args - 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)