Class InterfaceAdapter

java.lang.Object
org.htmlunit.corejs.javascript.InterfaceAdapter

public class InterfaceAdapter extends Object
Adapter to use JS function as implementation of Java interfaces with single method or multiple methods with the same signature.
  • Field Details

    • proxyHelper

      private final Object proxyHelper
  • Constructor Details

  • Method Details

    • create

      static Object create(Context cx, Class<?> cl, ScriptableObject object)
      Make glue object implementing interface cl that will call the supplied JS function when called. Only interfaces were all methods have the same signature is supported.
      Returns:
      The glue object or null if cl is not interface or has methods with different signatures.
    • isFunctionalMethodCandidate

      private static boolean isFunctionalMethodCandidate(Method method)
      We have to ignore java8 default methods and methods like 'equals', 'hashCode' and 'toString' as it occurs for example in the Comparator interface.
      Returns:
      true, if the function
    • invoke

      public Object invoke(ContextFactory cf, Object target, Scriptable topScope, Object thisObject, Method method, Object[] args)
    • invokeImpl

      Object invokeImpl(Context cx, Object target, Scriptable topScope, Object thisObject, Method method, Object[] args)