Class NewInstanceMetaMethod

All Implemented Interfaces:
MetaMember, Cloneable
Direct Known Subclasses:
GroovyCategorySupport.CategoryMethod

public class NewInstanceMetaMethod extends NewMetaMethod
A MetaMethod implementation where the underlying method is really a static helper method on some class but it appears to be an instance method on a class. This implementation is used to add new methods to the JDK writing them as normal static methods with the first parameter being the class on which the method is added.
  • Constructor Details

    • NewInstanceMetaMethod

      public NewInstanceMetaMethod(CachedMethod method)
      Constructs a new NewInstanceMetaMethod.
      Parameters:
      method - the cached static helper method
  • Method Details

    • isStatic

      public boolean isStatic()
      Indicates this method is not static (it appears as an instance method).
      Returns:
      false, as this wraps a static method to appear as an instance method
    • getModifiers

      public int getModifiers()
      Returns the modifiers for this method (PUBLIC without STATIC).
      Specified by:
      getModifiers in interface MetaMember
      Overrides:
      getModifiers in class ReflectionMetaMethod
      Returns:
      PUBLIC modifier only
    • invoke

      public Object invoke(Object object, Object[] arguments)
      Invokes the underlying static method with the object as the first argument. This adapts instance method calls to the underlying static method signature.
      Overrides:
      invoke in class ReflectionMetaMethod
      Parameters:
      object - the object to invoke the method on (passed as first argument to static method)
      arguments - the method arguments
      Returns:
      the method return value