Class NullMethod

java.lang.Object
org.jruby.internal.runtime.methods.DynamicMethod
org.jruby.internal.runtime.methods.NullMethod

public class NullMethod extends DynamicMethod
This class represents a singleton type of method used as a marker for breaking method lookup loops. Like UndefinedMethod, only one instance is ever created, it can't be invoked, and shouldn't be returned as though it were a real method.
  • Field Details

    • INSTANCE

      public static final NullMethod INSTANCE
  • Method Details

    • call

      public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule klazz, String name, IRubyObject[] args, Block block)
      The one implementation of call, which throws an exception because NullMethod can't be invoked.
      Specified by:
      call in class DynamicMethod
      Parameters:
      context - The thread context for the currently executing thread
      self - The 'self' or 'receiver' object to use for this call
      klazz - The Ruby class against which this method is binding
      name - The incoming name used to invoke this method
      args - The argument list to this invocation
      block - The block passed to this invocation
      Returns:
      The result of the call
      See Also:
    • dup

      public DynamicMethod dup()
      A dummy implementation of dup that just returns the singleton instance.
      Specified by:
      dup in class DynamicMethod
      Returns:
      The singleton instance
    • getInstance

      public static NullMethod getInstance()
      Retrieve the singleton instance.
      Returns:
      The singleton instance
    • setImplementationClass

      public void setImplementationClass(RubyModule implClass)
      Dummy override of setImplementationClass that does nothing.
      Overrides:
      setImplementationClass in class DynamicMethod
      Parameters:
      implClass - Ignored
    • setVisibility

      public void setVisibility(Visibility visibility)
      Dummy implementation of setVisibility that does nothing.
      Overrides:
      setVisibility in class DynamicMethod
      Parameters:
      visibility - Ignored
    • setCallConfig

      @Deprecated public void setCallConfig(CallConfiguration callConfig)
      Deprecated.
      Dummy implementation of setCallConfig that does nothing.
      Overrides:
      setCallConfig in class DynamicMethod
      Parameters:
      callConfig - Ignored
    • isCallableFrom

      public boolean isCallableFrom(IRubyObject caller, CallType callType)
      NullMethod is always visible because it's only used as a marker to break method lookup loops.
      Overrides:
      isCallableFrom in class DynamicMethod
      Parameters:
      caller - The calling object
      callType - The type of call
      Returns:
      true always