Class NativeJavaMethod

All Implemented Interfaces:
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:
  • Field Details

  • Constructor Details

    • NativeJavaMethod

      NativeJavaMethod(MemberBox[] methods)
    • NativeJavaMethod

      NativeJavaMethod(MemberBox[] methods, String name)
    • NativeJavaMethod

      NativeJavaMethod(MemberBox method, String name)
    • NativeJavaMethod

      public NativeJavaMethod(Method method, String name)
  • Method Details

    • getFunctionName

      public String getFunctionName()
      Overrides:
      getFunctionName in class BaseFunction
    • scriptSignature

      static String scriptSignature(Object[] values)
    • decompile

      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 String toString()
      Overrides:
      toString in class Object
    • call

      public Object call(Context cx, Scriptable scope, Scriptable thisObj, 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, Object[] args)
    • findFunction

      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. 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

      private static void printDebug(String msg, MemberBox member, Object[] args)