Package org.jruby

Class RubyModule

All Implemented Interfaces:
Serializable, Cloneable, Comparable<IRubyObject>, InstanceVariables, InternalVariables, IRubyObject, CoreObjectType
Direct Known Subclasses:
JavaPackage, RubyClass

public class RubyModule extends RubyObject
See Also:
  • Field Details

    • LOG

      private static final Logger LOG
    • CACHEPROXY_F

      public static final int CACHEPROXY_F
    • NEEDSIMPL_F

      public static final int NEEDSIMPL_F
    • REFINED_MODULE_F

      public static final int REFINED_MODULE_F
    • IS_OVERLAID_F

      public static final int IS_OVERLAID_F
    • OMOD_SHARED

      public static final int OMOD_SHARED
    • INCLUDED_INTO_REFINEMENT

      public static final int INCLUDED_INTO_REFINEMENT
    • MODULE_ALLOCATOR

      public static final ObjectAllocator MODULE_ALLOCATOR
    • NormalCacheEntryFactory

      protected static final RubyModule.CacheEntryFactory NormalCacheEntryFactory
    • cacheEntryFactory

      private volatile RubyModule.CacheEntryFactory cacheEntryFactory
    • kindOf

      public RubyModule.KindOf kindOf
    • id

      public final int id
    • idTest

      private MethodHandle idTest
      Pre-built test that takes ThreadContext, IRubyObject and checks that the object is a module with the same ID as this one.
    • parent

      public RubyModule parent
      The class/module within whose namespace this class/module resides.
    • baseName

      protected String baseName
      The base name of this class/module, excluding nesting. If null, this is an anonymous class.
    • cachedName

      private transient String cachedName
      The cached name, full class name e.g. Foo::Bar if this class and all containing classes are non-anonymous. The cached anonymous class name never changes and has a nonzero cost to calculate.
    • cachedRubyName

      private transient RubyString cachedRubyName
    • constants

      private volatile Map<String,RubyModule.ConstantEntry> constants
    • autoloads

      private volatile Map<String,RubyModule.Autoload> autoloads
    • methods

      protected volatile Map<String,DynamicMethod> methods
    • cachedMethods

      protected Map<String,CacheEntry> cachedMethods
    • generation

      protected int generation
    • generationObject

      protected Integer generationObject
    • includingHierarchies

      protected volatile Set<RubyClass> includingHierarchies
    • methodLocation

      protected volatile RubyModule methodLocation
      Where are the methods of this module/class located? This only happens as a result of prepend (see PrependedModule) where it moves all methods to a PrependedModule which will be beneath the actual module which was prepended.
    • classProviders

      private transient volatile Set<ClassProvider> classProviders
    • superClass

      protected RubyClass superClass
    • index

      @Deprecated public int index
      Deprecated.
      use RubyModule#getClassIndex()
      The index of this class in the ClassIndex. Only non-zero for native JRuby classes that have a corresponding entry in ClassIndex.
      See Also:
    • SCOPE_CAPTURING_METHODS

      @Deprecated public static final Set<String> SCOPE_CAPTURING_METHODS
      Deprecated.
    • classIndex

      protected ClassIndex classIndex
    • classVariables

      private volatile Map<String,IRubyObject> classVariables
    • refinements

      private volatile Map<RubyModule,RubyModule> refinements
      Refinements added to this module are stored here
    • activatedRefinements

      private volatile Map<RubyModule,IncludedModule> activatedRefinements
      A list of refinement hosts for this refinement
    • refinedClass

      volatile RubyModule refinedClass
      The class this refinement refines
    • definedAt

      private volatile RubyModule definedAt
      The module where this refinement was defined
    • CLASSVARS_UPDATER

      private static final AtomicReferenceFieldUpdater<RubyModule,Map> CLASSVARS_UPDATER
    • methodInvalidator

      protected final Invalidator methodInvalidator
    • javaProxy

      private boolean javaProxy
      Whether this class proxies a normal Java class
    • LOOKUP

      private static final MethodHandles.Lookup LOOKUP
    • testModuleMatch

      private static final MethodHandle testModuleMatch
      A handle for invoking the module ID test, to be reused for all idTest handles below.
  • Constructor Details

    • RubyModule

      protected RubyModule(Ruby runtime, RubyClass metaClass, boolean objectSpace)
      separate path for MetaClass construction
    • RubyModule

      protected RubyModule(Ruby runtime, RubyClass metaClass)
      used by MODULE_ALLOCATOR and RubyClass constructors
    • RubyModule

      protected RubyModule(Ruby runtime)
      standard path for Module construction
  • Method Details

    • createModuleClass

      public static RubyClass createModuleClass(Ruby runtime, RubyClass moduleClass)
    • checkValidBindTargetFrom

      public void checkValidBindTargetFrom(ThreadContext context, RubyModule originModule, boolean fromBind) throws RaiseException
      Throws:
      RaiseException
    • getClassIndex

      public ClassIndex getClassIndex()
      Get the ClassIndex for this class. Will be NO_CLASS for non-core types.
    • setClassIndex

      void setClassIndex(ClassIndex classIndex)
      Set the ClassIndex for this core class. Only used at boot time for core types.
      Parameters:
      classIndex - the ClassIndex for this type
    • autoload

      public IRubyObject autoload(ThreadContext context, IRubyObject symbol, IRubyObject file)
    • autoload_p

      public IRubyObject autoload_p(ThreadContext context, IRubyObject symbol)
    • getNativeClassIndex

      public ClassIndex getNativeClassIndex()
      Description copied from class: RubyObject
      This is overridden in the other concrete Java builtins to provide a fast way to determine what type they are. Will generally return a value from org.jruby.runtime.ClassIndex
      Specified by:
      getNativeClassIndex in interface CoreObjectType
      Overrides:
      getNativeClassIndex in class RubyObject
      See Also:
    • isModule

      public boolean isModule()
      Description copied from class: RubyBasicObject
      Specifically polymorphic method that are meant to be overridden by modules to specify that they are modules in an easy way.
      Specified by:
      isModule in interface IRubyObject
      Overrides:
      isModule in class RubyBasicObject
      Returns:
      true if an object is Ruby Module instance (note that it will return false for Ruby Classes). If is_a? semantics is required, use (someObject instanceof RubyModule) instead.
    • isClass

      public boolean isClass()
      Description copied from class: RubyBasicObject
      Specifically polymorphic method that are meant to be overridden by classes to specify that they are classes in an easy way.
      Specified by:
      isClass in interface IRubyObject
      Overrides:
      isClass in class RubyBasicObject
      Returns:
      true if an object is Ruby Class instance (note that it will return false for Ruby singleton classes). If is_a? semantics is required, use (someObject instanceof RubyClass/MetaClass) instead.
    • isSingleton

      public boolean isSingleton()
    • isInstance

      public boolean isInstance(IRubyObject object)
    • getConstantMap

      public Map<String,RubyModule.ConstantEntry> getConstantMap()
    • getConstantMapForWrite

      public Map<String,RubyModule.ConstantEntry> getConstantMapForWrite()
    • getAutoloadMap

      protected Map<String,RubyModule.Autoload> getAutoloadMap()
      AutoloadMap must be accessed after checking ConstantMap. Checking UNDEF value in constantMap works as a guard. For looking up constant, check constantMap first then try to get an Autoload object from autoloadMap. For setting constant, update constantMap first and remove an Autoload object from autoloadMap.
    • getAutoloadMapForWrite

      protected Map<String,RubyModule.Autoload> getAutoloadMapForWrite()
    • addIncludingHierarchy

      public void addIncludingHierarchy(IncludedModule hierarchy)
    • getIdTest

      public final MethodHandle getIdTest()
    • newIdTest

      protected final MethodHandle newIdTest()
    • needsImplementer

      public boolean needsImplementer()
    • newModule

      public static RubyModule newModule(Ruby runtime)
      rb_module_new
    • newModule

      public static RubyModule newModule(Ruby runtime, String name, RubyModule parent, boolean setParent)
      rb_module_new/rb_define_module_id/rb_name_class/rb_set_class_path
    • addClassProvider

      public final void addClassProvider(ClassProvider provider)
    • removeClassProvider

      public final void removeClassProvider(ClassProvider provider)
    • checkForCyclicInclude

      private void checkForCyclicInclude(RubyModule m) throws RaiseException
      Throws:
      RaiseException
    • checkForCyclicPrepend

      protected void checkForCyclicPrepend(RubyModule m) throws RaiseException
      Throws:
      RaiseException
    • searchProvidersForClass

      private RubyClass searchProvidersForClass(String name, RubyClass superClazz)
    • searchProvidersForModule

      private RubyModule searchProvidersForModule(String name)
    • getSuperClass

      public RubyClass getSuperClass()
      Getter for property superClass.
      Returns:
      Value of property superClass.
    • setSuperClass

      public void setSuperClass(RubyClass superClass)
    • getParent

      public RubyModule getParent()
    • setParent

      public void setParent(RubyModule parent)
    • getMethodLocation

      public RubyModule getMethodLocation()
    • setMethodLocation

      public void setMethodLocation(RubyModule module)
    • getMethods

      public Map<String,DynamicMethod> getMethods()
    • getMethodsForWrite

      public Map<String,DynamicMethod> getMethodsForWrite()
    • putMethod

      public DynamicMethod putMethod(Ruby runtime, String id, DynamicMethod method)
      Parameters:
      runtime -
      id - identifier string (8859_1). Matching entry in symbol table.
      method -
      Returns:
      method
    • isIncluded

      public boolean isIncluded()
      Is this module one that in an included one (e.g. an IncludedModuleWrapper).
      See Also:
    • isPrepended

      public boolean isPrepended()
    • getOrigin

      public RubyModule getOrigin()
      In an included or prepended module what is the ACTUAL module it represents?
      Returns:
      the actual module of an included/prepended module.
    • getNonIncludedClass

      @Deprecated public RubyModule getNonIncludedClass()
      Deprecated.
    • getDelegate

      public RubyModule getDelegate()
    • getRealModule

      public RubyModule getRealModule()
      Get the "real" module, either the current one or the nearest ancestor that is not a singleton or include wrapper. See RubyClass.getRealClass().
      Returns:
      the nearest non-singleton non-include module in the hierarchy
    • getBaseName

      public String getBaseName()
      Get the base name of this class, or null if it is an anonymous class.
      Returns:
      base name of the class
    • setBaseName

      public void setBaseName(String name)
      Set the base name of the class. If null, the class effectively becomes anonymous (though constants elsewhere may reference it).
      Parameters:
      name - the new base name of the class
    • getName

      public String getName()
      Generate a fully-qualified class name or a #-style name for anonymous and singleton classes. Ruby C equivalent = "classname"
      Returns:
      The generated class name
    • rubyName

      public RubyString rubyName()
      Generate a fully-qualified class name or a #-style name for anonymous and singleton classes which is properly encoded. The returned string is always frozen.
      Returns:
      a properly encoded class name. Note: getId() is only really valid for ASCII values. This should be favored over using it.
    • rubyBaseName

      public RubyString rubyBaseName()
    • calculateAnonymousRubyName

      private RubyString calculateAnonymousRubyName()
    • calculateRubyName

      private RubyString calculateRubyName()
    • getSimpleName

      public String getSimpleName()
      Get the "simple" name for the class, which is either the "base" name or the "anonymous" class name.
      Returns:
      the "simple" name of the class
    • calculateName

      private String calculateName()
      Recalculate the fully-qualified name of this class/module.
    • calculateAnonymousName

      private String calculateAnonymousName()
    • refine

      public IRubyObject refine(ThreadContext context, IRubyObject klass, Block block)
    • createNewRefinedModule

      private RubyModule createNewRefinedModule(ThreadContext context, RubyModule klass)
    • refinementSuperclass

      private static RubyClass refinementSuperclass(Ruby runtime, RubyModule superClass)
    • yieldRefineBlock

      private void yieldRefineBlock(ThreadContext context, RubyModule refinement, Block block)
    • getAlreadyActivatedRefinementWrapper

      private RubyClass getAlreadyActivatedRefinementWrapper(RubyClass classWeAreRefining, RubyModule refinement)
    • addActivatedRefinement

      private void addActivatedRefinement(ThreadContext context, RubyModule moduleToRefine, RubyModule refinement)
    • using

      public IRubyObject using(ThreadContext context, IRubyObject refinedModule)
    • usingModule

      public static void usingModule(ThreadContext context, RubyModule cref, IRubyObject refinedModule)
    • usingModuleRecursive

      private static void usingModuleRecursive(RubyModule cref, RubyModule module)
    • usingRefinement

      private static void usingRefinement(Ruby runtime, RubyModule cref, RubyModule klass, RubyModule module)
    • newRefinementsMap

      public static Map<RubyModule,RubyModule> newRefinementsMap(Map<RubyModule,RubyModule> refinements)
    • newRefinementsMap

      public static Map<RubyModule,RubyModule> newRefinementsMap()
    • newActivatedRefinementsMap

      public static Map<RubyModule,IncludedModule> newActivatedRefinementsMap()
    • used_modules

      public IRubyObject used_modules(ThreadContext context)
    • newIncludeClass

      @Deprecated public IncludedModuleWrapper newIncludeClass(RubyClass superClazz)
      Deprecated.
      Create a wrapper to use for including the specified module into this one. Ruby C equivalent = "include_class_new"
      Returns:
      The module wrapper
    • getModule

      public RubyModule getModule(String name)
      Finds a module that is within the current module (or class).
      Parameters:
      name - to be found in this module (or class)
      Returns:
      the module or null if no such module
      Since:
      9.2
    • getClass

      public RubyClass getClass(String name)
      Finds a class that is within the current module (or class).
      Parameters:
      name - to be found in this module (or class)
      Returns:
      the class or null if no such class
    • fastGetClass

      @Deprecated public RubyClass fastGetClass(String internedName)
      Deprecated.
    • prependModule

      public void prependModule(RubyModule module)
      Prepend a new module to this module or class. MRI: rb_prepend_module
      Parameters:
      module - The module to include
    • prependModule

      @Deprecated public void prependModule(IRubyObject arg)
      Deprecated.
    • includeModule

      public void includeModule(IRubyObject arg)
      Include a new module in this module or class.
      Parameters:
      arg - The module to include
    • defineAnnotatedMethod

      public void defineAnnotatedMethod(Class clazz, String name)
    • defineAnnotatedConstants

      public final void defineAnnotatedConstants(Class clazz)
    • defineAnnotatedConstant

      public final boolean defineAnnotatedConstant(Field field)
    • defineAnnotatedMethods

      public void defineAnnotatedMethods(Class clazz)
    • loadPopulatorFor

      public static TypePopulator loadPopulatorFor(Class<?> type)
    • defineAnnotatedMethodsIndividually

      public final void defineAnnotatedMethodsIndividually(Class clazz)
    • defineAnnotatedMethod

      public final boolean defineAnnotatedMethod(String name, List<JavaMethodDescriptor> methods, MethodFactory methodFactory)
    • defineAnnotatedMethod

      public final boolean defineAnnotatedMethod(Method method, MethodFactory methodFactory)
    • defineAnnotatedMethod

      public final boolean defineAnnotatedMethod(String name, JavaMethodDescriptor desc, MethodFactory methodFactory)
    • undefineMethod

      public void undefineMethod(String name)
    • undef

      public void undef(ThreadContext context, String name)
      rb_undef
    • include_p

      public IRubyObject include_p(ThreadContext context, IRubyObject arg)
    • singleton_class_p

      public IRubyObject singleton_class_p(ThreadContext context)
    • addMethod

      public void addMethod(String id, DynamicMethod method)
    • addRefinedMethodEntry

      private void addRefinedMethodEntry(String id, DynamicMethod method)
    • addMethodInternal

      public final void addMethodInternal(String name, DynamicMethod method)
    • addMethodAtBootTimeOnly

      public final void addMethodAtBootTimeOnly(String id, DynamicMethod method)
      Deprecated.
      No longer used, internal API!
      This method is not intended for use by normal users; it is a fast-path method that skips synchronization and hierarchy invalidation to speed boot-time method definition.
      Parameters:
      id - The name to which to bind the method
      method - The method to bind
    • removeMethod

      public void removeMethod(ThreadContext context, String id)
    • warnMethodRemoval

      private static void warnMethodRemoval(ThreadContext context, String id)
    • searchMethod

      public final DynamicMethod searchMethod(String name)
      Search through this module and supermodules for method definitions. Cache superclass definitions in this class.
      Parameters:
      name - The name of the method to search for
      Returns:
      The method, or UndefinedMethod if not found
    • searchWithCache

      public CacheEntry searchWithCache(String name)
      Search for the named method in this class and in superclasses, and if found return the CacheEntry representing the method and this class's serial number. MRI: method_entry_get
      Parameters:
      name - the method name
      Returns:
      the CacheEntry corresponding to the method and this class's serial number
    • searchWithRefinements

      public CacheEntry searchWithRefinements(String name, StaticScope refinedScope)
      Search for the named method in this class and in superclasses applying refinements from the given scope. If found return the method; otherwise, return UndefinedMethod.
      Parameters:
      name - the method name
      refinedScope - the scope containing refinements to search
      Returns:
      the method or UndefinedMethod
    • searchWithCache

      public final CacheEntry searchWithCache(String id, boolean cacheUndef)
      Search through this module and supermodules for method definitions. Cache superclass definitions in this class. MRI: method_entry_get
      Parameters:
      id - The name of the method to search for
      cacheUndef - Flag for caching UndefinedMethod. This should normally be true.
      Returns:
      The method, or UndefinedMethod if not found
    • searchWithCacheAndRefinements

      private final CacheEntry searchWithCacheAndRefinements(String id, boolean cacheUndef, StaticScope refinedScope)
    • refinedMethodOriginalMethodEntry

      private CacheEntry refinedMethodOriginalMethodEntry(Map<RubyModule,RubyModule> refinements, String id, boolean cacheUndef, CacheEntry entry)
    • searchWithCacheMiss

      private CacheEntry searchWithCacheMiss(Ruby runtime, String id, boolean cacheUndef)
      Search through this module and supermodules for method definitions after cacheHit(String) failed to return a result. Cache superclass definitions in this class. MRI: method_entry_get_without_cache
      Parameters:
      id - The name of the method to search for
      cacheUndef - Flag for caching UndefinedMethod. This should normally be true.
      Returns:
      The method, or UndefinedMethod if not found
    • getCacheToken

      @Deprecated public final int getCacheToken()
      Deprecated.
    • getGeneration

      public final int getGeneration()
    • getGenerationObject

      public final Integer getGenerationObject()
    • getCachedMethods

      private final Map<String,CacheEntry> getCachedMethods()
    • getCachedMethodsForWrite

      private final Map<String,CacheEntry> getCachedMethodsForWrite()
    • cacheHit

      private CacheEntry cacheHit(String name)
    • invalidateConstantCacheForModuleInclusion

      private void invalidateConstantCacheForModuleInclusion(RubyModule module)
    • becomeSynchronized

      public void becomeSynchronized()
    • isSynchronized

      public boolean isSynchronized()
    • addToCache

      protected CacheEntry addToCache(String id, DynamicMethod method, RubyModule sourceModule, int token)
    • addToCache

      protected CacheEntry addToCache(String id, CacheEntry entry)
    • searchMethodInner

      public DynamicMethod searchMethodInner(String id)
    • searchMethodEntryInner

      public CacheEntry searchMethodEntryInner(String id)
    • searchMethodLateral

      public DynamicMethod searchMethodLateral(String id)
      Searches for a method up until the superclass, but include modules. This is for Concrete java ctor initialization TODO: add a cache?
    • resolveRefinedMethod

      public CacheEntry resolveRefinedMethod(Map<RubyModule,RubyModule> refinements, CacheEntry entry, String id, boolean cacheUndef)
    • findRefinement

      private static RubyModule findRefinement(Map<RubyModule,RubyModule> refinements, RubyModule target)
    • searchMethodCommon

      protected DynamicMethod searchMethodCommon(String id)
    • invalidateCacheDescendants

      public void invalidateCacheDescendants()
    • invalidateCoreClasses

      protected void invalidateCoreClasses()
    • getInvalidator

      public Invalidator getInvalidator()
    • updateGeneration

      public void updateGeneration()
    • updateGeneration

      private void updateGeneration(Ruby runtime)
    • invalidateCacheDescendantsInner

      @Deprecated protected void invalidateCacheDescendantsInner()
      Deprecated.
    • invalidateConstantCache

      protected void invalidateConstantCache(String constantName)
    • invalidateConstantCaches

      protected void invalidateConstantCaches(Set<String> constantNames)
    • retrieveMethod

      public DynamicMethod retrieveMethod(String name)
      Search through this module and supermodules for method definitions. Cache superclass definitions in this class.
      Parameters:
      name - The name of the method to search for
      Returns:
      The method, or UndefinedMethod if not found
    • findImplementer

      public RubyModule findImplementer(RubyModule clazz)
      Find the given class in this hierarchy, considering modules along the way.
      Parameters:
      clazz - the class to find
      Returns:
      The method, or UndefinedMethod if not found
    • addModuleFunction

      public void addModuleFunction(String name, DynamicMethod method)
    • defineAlias

      public void defineAlias(String name, String oldName)
      rb_alias
    • putAlias

      public void putAlias(String id, DynamicMethod method, String oldName)
      Parameters:
      id -
      method -
      oldName -
    • putAlias

      public void putAlias(String id, CacheEntry entry, String oldName)
      Alias the method contained in the given CacheEntry as a new entry in this module.
      Parameters:
      id -
      entry -
      oldName -
    • searchForAliasMethod

      private CacheEntry searchForAliasMethod(Ruby runtime, String id)
    • checkAliasFrameAccesses

      private void checkAliasFrameAccesses(Ruby runtime, String id, String newName, DynamicMethod method)
    • defineOrGetClassUnder

      public RubyClass defineOrGetClassUnder(String name, RubyClass superClazz)
      this method should be used only by interpreter or compiler
    • defineOrGetClassUnder

      public RubyClass defineOrGetClassUnder(String name, RubyClass superClazz, ObjectAllocator allocator)
    • isReifiable

      private boolean isReifiable(Ruby runtime, RubyClass superClass)
      Determine if a new child of the given class can have its variables reified.
    • defineOrGetModuleUnder

      public RubyModule defineOrGetModuleUnder(String name)
      this method should be used only by interpreter or compiler
    • defineClassUnder

      public RubyClass defineClassUnder(String name, RubyClass superClass, ObjectAllocator allocator)
      rb_define_class_under this method should be used only as an API to define/open nested classes
    • defineModuleUnder

      public RubyModule defineModuleUnder(String name)
      rb_define_module_under this method should be used only as an API to define/open nested module
    • addAccessor

      private void addAccessor(ThreadContext context, RubySymbol identifier, Visibility visibility, boolean readable, boolean writeable)
    • setMethodVisibility

      public void setMethodVisibility(IRubyObject[] methods, Visibility visibility)
      set_method_visibility
    • exportMethod

      public void exportMethod(String name, Visibility visibility)
      rb_export_method
    • deepMethodSearch

      private CacheEntry deepMethodSearch(String id, Ruby runtime)
    • undefinedMethodMessage

      public static String undefinedMethodMessage(Ruby runtime, IRubyObject name, IRubyObject modName, boolean isModule)
    • isMethodBound

      public boolean isMethodBound(String name, boolean checkVisibility)
      MRI: rb_method_boundp
    • respondsToMethod

      public boolean respondsToMethod(String name, boolean checkVisibility, StaticScope scope)
    • respondsToMethod

      public boolean respondsToMethod(String name, boolean checkVisibility)
    • isMethodBound

      @Deprecated public boolean isMethodBound(String name, boolean checkVisibility, boolean checkRespondTo)
      Deprecated.
    • newMethod

      public final IRubyObject newMethod(IRubyObject receiver, String methodName, boolean bound, Visibility visibility)
    • newMethod

      public final IRubyObject newMethod(IRubyObject receiver, String methodName, boolean bound, Visibility visibility, boolean respondToMissing)
    • newMethod

      public IRubyObject newMethod(IRubyObject receiver, String methodName, boolean bound, Visibility visibility, boolean respondToMissing, boolean priv)
    • define_method

      public IRubyObject define_method(ThreadContext context, IRubyObject arg0, Block block)
    • getCurrentVisibilityForDefineMethod

      private Visibility getCurrentVisibilityForDefineMethod(ThreadContext context)
    • defineMethodFromBlock

      public IRubyObject defineMethodFromBlock(ThreadContext context, IRubyObject arg0, Block block, Visibility visibility)
    • define_method

      public IRubyObject define_method(ThreadContext context, IRubyObject arg0, IRubyObject arg1, Block block)
    • defineMethodFromCallable

      public IRubyObject defineMethodFromCallable(ThreadContext context, IRubyObject arg0, IRubyObject arg1, Visibility visibility)
    • define_method

      @Deprecated public IRubyObject define_method(ThreadContext context, IRubyObject[] args, Block block)
      Deprecated.
    • createProcMethod

      private DynamicMethod createProcMethod(Ruby runtime, String name, Visibility visibility, Block block)
    • name

      public IRubyObject name()
    • name

      public IRubyObject name(ThreadContext context)
    • name19

      @Deprecated public IRubyObject name19()
      Deprecated.
    • cloneMethods

      protected final IRubyObject cloneMethods(RubyModule clone)
    • initialize_copy

      public IRubyObject initialize_copy(IRubyObject original)
      mri: rb_mod_init_copy
      Overrides:
      initialize_copy in class RubyBasicObject
    • checkSafeTypeToCopy

      private void checkSafeTypeToCopy(RubyClass original)
    • syncConstants

      public void syncConstants(RubyModule other)
    • syncClassVariables

      public void syncClassVariables(RubyModule other)
    • included_modules

      public RubyArray included_modules(ThreadContext context)
      rb_mod_included_modules
    • hasPrepends

      public boolean hasPrepends()
    • ancestors

      public RubyArray ancestors(ThreadContext context)
      rb_mod_ancestors
    • ancestors

      @Deprecated public RubyArray ancestors()
      Deprecated.
    • getAncestorList

      public List<IRubyObject> getAncestorList()
    • hasModuleInPrepends

      public boolean hasModuleInPrepends(RubyModule type)
    • getPrependCeiling

      private RubyModule getPrependCeiling()
    • hasModuleInHierarchy

      public boolean hasModuleInHierarchy(RubyModule type)
    • hashCode

      public int hashCode()
      Description copied from class: RubyObject
      This override does not do "checked" dispatch since Object usually has #hash defined.
      Overrides:
      hashCode in class RubyObject
      See Also:
    • hash

      public RubyFixnum hash()
      Description copied from class: RubyBasicObject
      rb_obj_id Will return the hash code of this object. In comparison to MRI, this method will use the Java identity hash code instead of using rb_obj_id, since the usage of id in JRuby will incur the cost of some. ObjectSpace maintenance.
      Overrides:
      hash in class RubyBasicObject
    • to_s

      public RubyString to_s()
      rb_mod_to_s
      Overrides:
      to_s in class RubyBasicObject
    • op_eqq

      public RubyBoolean op_eqq(ThreadContext context, IRubyObject obj)
      rb_mod_eqq
      Specified by:
      op_eqq in interface IRubyObject
      Overrides:
      op_eqq in class RubyObject
    • equals

      public boolean equals(Object other)
      We override equals here to provide a faster path, since equality for modules is pretty cut and dried.
      Overrides:
      equals in class RubyObject
      Parameters:
      other - The object to check for equality
      Returns:
      true if reference equality, false otherwise
      See Also:
    • op_equal

      public IRubyObject op_equal(ThreadContext context, IRubyObject other)
      Description copied from class: RubyBasicObject
      rb_obj_equal Will by default use identity equality to compare objects. This follows the Ruby semantics. The name of this method doesn't follow the convention because hierarchy problems
      Specified by:
      op_equal in interface IRubyObject
      Overrides:
      op_equal in class RubyBasicObject
    • freeze

      public final IRubyObject freeze(ThreadContext context)
      rb_mod_freeze
      Overrides:
      freeze in class RubyBasicObject
    • op_le

      public IRubyObject op_le(IRubyObject arg)
      MRI: rb_class_inherited_p
    • searchAncestor

      protected RubyModule searchAncestor(RubyModule c)
    • op_lt

      public IRubyObject op_lt(IRubyObject obj)
      rb_mod_lt
    • op_ge

      public IRubyObject op_ge(IRubyObject obj)
      rb_mod_ge
    • op_gt

      public IRubyObject op_gt(IRubyObject obj)
      rb_mod_gt
    • op_cmp

      public IRubyObject op_cmp(IRubyObject obj)
      rb_mod_cmp
    • isKindOfModule

      public boolean isKindOfModule(RubyModule type)
    • isSame

      protected boolean isSame(RubyModule module)
    • isSameOrigin

      protected boolean isSameOrigin(RubyModule other)
    • initialize

      public IRubyObject initialize(ThreadContext context, Block block)
      rb_mod_initialize
    • addReadWriteAttribute

      public void addReadWriteAttribute(ThreadContext context, String name)
    • addReadAttribute

      public void addReadAttribute(ThreadContext context, String name)
    • addWriteAttribute

      public void addWriteAttribute(ThreadContext context, String name)
    • attr

      public IRubyObject attr(ThreadContext context, IRubyObject[] args)
      rb_mod_attr
    • attr19

      @Deprecated public IRubyObject attr19(ThreadContext context, IRubyObject[] args)
      Deprecated.
    • attr_reader

      @Deprecated public IRubyObject attr_reader(IRubyObject[] args)
      Deprecated.
    • attr_reader

      public IRubyObject attr_reader(ThreadContext context, IRubyObject[] args)
      rb_mod_attr_reader
    • attr_writer

      public IRubyObject attr_writer(ThreadContext context, IRubyObject[] args)
      rb_mod_attr_writer
    • attr_accessor

      @Deprecated public IRubyObject attr_accessor(IRubyObject[] args)
      Deprecated.
    • attr_accessor

      public IRubyObject attr_accessor(ThreadContext context, IRubyObject[] args)
      rb_mod_attr_accessor Note: this method should not be called from Java in most cases, since it depends on Ruby frame state for visibility. Use add[Read/Write]Attribute instead.
    • instance_methods

      private RubyArray instance_methods(IRubyObject[] args, Visibility visibility, boolean not)
      Get a list of all instance methods names of the provided visibility unless not is true, then getService all methods which are not the provided
      Parameters:
      args - passed into one of the Ruby instance_method methods
      visibility - to find matching instance methods against
      not - if true only find methods not matching supplied visibility
      Returns:
      a RubyArray of instance method names
    • instanceMethods

      public RubyArray instanceMethods(IRubyObject[] args, Visibility visibility, boolean obj, boolean not)
    • instanceMethods

      public RubyArray instanceMethods(Visibility visibility, boolean includeSuper, boolean obj, boolean not)
    • populateInstanceMethodNames

      final void populateInstanceMethodNames(Set<String> seen, RubyArray ary, Visibility visibility, boolean obj, boolean not, boolean recur)
    • addMethodSymbols

      protected void addMethodSymbols(Ruby runtime, Set<String> seen, RubyArray ary, boolean not, Visibility visibility)
    • instance_methods

      public RubyArray instance_methods(IRubyObject[] args)
    • instance_methods19

      public RubyArray instance_methods19(IRubyObject[] args)
    • public_instance_methods

      public RubyArray public_instance_methods(IRubyObject[] args)
    • public_instance_methods19

      public RubyArray public_instance_methods19(IRubyObject[] args)
    • instance_method

      public IRubyObject instance_method(IRubyObject symbol)
    • public_instance_method

      public IRubyObject public_instance_method(IRubyObject symbol)
    • protected_instance_methods

      public RubyArray protected_instance_methods(IRubyObject[] args)
      rb_class_protected_instance_methods
    • protected_instance_methods19

      @Deprecated public RubyArray protected_instance_methods19(IRubyObject[] args)
      Deprecated.
    • private_instance_methods

      public RubyArray private_instance_methods(IRubyObject[] args)
      rb_class_private_instance_methods
    • private_instance_methods19

      @Deprecated public RubyArray private_instance_methods19(IRubyObject[] args)
      Deprecated.
    • prepend_features

      public RubyModule prepend_features(IRubyObject include)
      rb_mod_prepend_features
    • append_features

      public RubyModule append_features(IRubyObject include)
      rb_mod_append_features
    • extend_object

      public IRubyObject extend_object(IRubyObject obj)
      rb_mod_extend_object
    • include

      public RubyModule include(IRubyObject[] modules)
      rb_mod_include
    • include

      public RubyModule include(ThreadContext context, IRubyObject module)
    • included

      public IRubyObject included(ThreadContext context, IRubyObject other)
    • extended

      public IRubyObject extended(ThreadContext context, IRubyObject other, Block block)
    • mix

      public IRubyObject mix(ThreadContext context, IRubyObject mod)
    • mix

      public IRubyObject mix(ThreadContext context, IRubyObject mod, IRubyObject hash0)
    • setVisibility

      private void setVisibility(ThreadContext context, IRubyObject[] args, Visibility visibility)
    • rbPublic

      public RubyModule rbPublic(ThreadContext context, IRubyObject[] args)
      rb_mod_public
    • rbProtected

      public RubyModule rbProtected(ThreadContext context, IRubyObject[] args)
      rb_mod_protected
    • rbPrivate

      public RubyModule rbPrivate(ThreadContext context, IRubyObject[] args)
      rb_mod_private
    • module_function

      public RubyModule module_function(ThreadContext context, IRubyObject[] args)
      rb_mod_modfunc
    • method_added

      public IRubyObject method_added(ThreadContext context, IRubyObject nothing)
    • method_removed

      public IRubyObject method_removed(ThreadContext context, IRubyObject nothing)
    • method_undefined

      public IRubyObject method_undefined(ThreadContext context, IRubyObject nothing)
    • method_defined_p

      public RubyBoolean method_defined_p(ThreadContext context, IRubyObject symbol)
    • method_defined_p

      public RubyBoolean method_defined_p(ThreadContext context, IRubyObject symbol, IRubyObject includeSuper)
    • public_method_defined

      public IRubyObject public_method_defined(ThreadContext context, IRubyObject symbol)
    • public_method_defined

      public IRubyObject public_method_defined(ThreadContext context, IRubyObject symbol, IRubyObject includeSuper)
    • protected_method_defined

      public IRubyObject protected_method_defined(ThreadContext context, IRubyObject symbol)
    • protected_method_defined

      public IRubyObject protected_method_defined(ThreadContext context, IRubyObject symbol, IRubyObject includeSuper)
    • private_method_defined

      public IRubyObject private_method_defined(ThreadContext context, IRubyObject symbol)
    • private_method_defined

      public IRubyObject private_method_defined(ThreadContext context, IRubyObject symbol, IRubyObject includeSuper)
    • checkMethodVisibility

      private Visibility checkMethodVisibility(ThreadContext context, IRubyObject symbol, boolean parents)
    • public_class_method

      public RubyModule public_class_method(IRubyObject[] args)
    • private_class_method

      public RubyModule private_class_method(IRubyObject[] args)
    • alias_method

      public RubyModule alias_method(ThreadContext context, IRubyObject newId, IRubyObject oldId)
    • undef_method

      public RubyModule undef_method(ThreadContext context, IRubyObject[] args)
    • module_eval

      public IRubyObject module_eval(ThreadContext context, Block block)
    • module_eval

      public IRubyObject module_eval(ThreadContext context, IRubyObject arg0, Block block)
    • module_eval

      public IRubyObject module_eval(ThreadContext context, IRubyObject arg0, IRubyObject arg1, Block block)
    • module_eval

      public IRubyObject module_eval(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block block)
    • module_eval

      @Deprecated public IRubyObject module_eval(ThreadContext context, IRubyObject[] args, Block block)
      Deprecated.
    • module_exec

      public IRubyObject module_exec(ThreadContext context, Block block)
    • module_exec

      public IRubyObject module_exec(ThreadContext context, IRubyObject[] args, Block block)
    • remove_method

      public RubyModule remove_method(ThreadContext context, IRubyObject[] args)
    • marshalTo

      public static void marshalTo(RubyModule module, MarshalStream output) throws IOException
      Throws:
      IOException
    • unmarshalFrom

      public static RubyModule unmarshalFrom(UnmarshalStream input) throws IOException
      Throws:
      IOException
    • nesting

      public static RubyArray nesting(ThreadContext context, IRubyObject recv, Block block)
      Return an array of nested modules or classes.
    • doIncludeModule

      private void doIncludeModule(RubyModule baseModule)
      Include the given module and all related modules into the hierarchy above this module/class. Inspects the hierarchy to ensure the same module isn't included twice, and selects an appropriate insertion point for each incoming module.
      Parameters:
      baseModule - The module to include, along with any modules it itself includes
    • doPrependModule

      private void doPrependModule(RubyModule baseModule)
      Prepend the given module and all related modules into the hierarchy above this module/class. Inspects the hierarchy to ensure the same module isn't included twice, and selects an appropriate insertion point for each incoming module.
      Parameters:
      baseModule - The module to prepend, along with any modules it itself includes
    • gatherModules

      private List<RubyModule> gatherModules(RubyModule baseModule)
      Gather all modules that would be included by including the given module. The resulting list contains the given module and its (zero or more) module-wrapping superclasses.
      Parameters:
      baseModule - The base module from which to aggregate modules
      Returns:
      A list of all modules that would be included by including the given module
    • proceedWithInclude

      private RubyModule proceedWithInclude(RubyModule insertAbove, RubyModule moduleToInclude)
      Actually proceed with including the specified module above the given target in a hierarchy. Return the new module wrapper.
      Parameters:
      insertAbove - The hierarchy target above which to include the wrapped module
      moduleToInclude - The module to wrap and include
      Returns:
      The new module wrapper resulting from this include
    • proceedWithPrepend

      private RubyModule proceedWithPrepend(RubyModule insertBelow, RubyModule moduleToPrepend)
      Actually proceed with prepending the specified module below the given target in a hierarchy. Return the new module wrapper.
      Parameters:
      insertBelow - The hierarchy target below which to include the wrapped module
      moduleToPrepend - The module to wrap and prepend
      Returns:
      The new module wrapper resulting from this prepend
    • class_variable_defined_p

      public IRubyObject class_variable_defined_p(ThreadContext context, IRubyObject var)
    • class_variable_get

      public IRubyObject class_variable_get(IRubyObject name)
      rb_mod_cvar_get
    • class_variable_get19

      public IRubyObject class_variable_get19(IRubyObject name)
    • class_variable_set

      public IRubyObject class_variable_set(IRubyObject name, IRubyObject value)
      rb_mod_cvar_set
    • class_variable_set19

      public IRubyObject class_variable_set19(IRubyObject name, IRubyObject value)
    • remove_class_variable

      public IRubyObject remove_class_variable(ThreadContext context, IRubyObject name)
      rb_mod_remove_cvar
    • remove_class_variable19

      public IRubyObject remove_class_variable19(ThreadContext context, IRubyObject name)
    • class_variables19

      @Deprecated public RubyArray class_variables19(ThreadContext context)
      Deprecated.
    • class_variables

      public RubyArray class_variables(ThreadContext context)
    • class_variables

      public RubyArray class_variables(ThreadContext context, IRubyObject inherit)
    • classVariablesCommon

      private Collection<String> classVariablesCommon(boolean inherit)
    • const_defined_p

      public RubyBoolean const_defined_p(ThreadContext context, IRubyObject name)
      rb_mod_const_defined
    • const_defined_p

      public RubyBoolean const_defined_p(ThreadContext context, IRubyObject name, IRubyObject recurse)
    • constDefined

      private boolean constDefined(Ruby runtime, IRubyObject name, boolean inherit)
    • const_get

      public IRubyObject const_get(IRubyObject symbol)
    • const_get_1_9

      @Deprecated public IRubyObject const_get_1_9(ThreadContext context, IRubyObject[] args)
      Deprecated.
    • const_get_2_0

      @Deprecated public IRubyObject const_get_2_0(ThreadContext context, IRubyObject[] args)
      Deprecated.
    • const_get

      public IRubyObject const_get(ThreadContext context, IRubyObject... args)
      rb_mod_const_get
    • const_set

      public IRubyObject const_set(IRubyObject name, IRubyObject value)
      rb_mod_const_set
    • remove_const

      public IRubyObject remove_const(ThreadContext context, IRubyObject rubyName)
    • hasConstantInHierarchy

      private boolean hasConstantInHierarchy(String name)
    • const_missing

      public IRubyObject const_missing(ThreadContext context, IRubyObject rubyName, Block block)
      Base implementation of Module#const_missing, throws NameError for specific missing constant.
      Parameters:
      rubyName - The constant name which was found to be missing
      Returns:
      Nothing! Absolutely nothing! (though subclasses might choose to return something)
    • constants

      public RubyArray constants(ThreadContext context)
    • constants

      public RubyArray constants(ThreadContext context, IRubyObject allConstants)
    • constants19

      @Deprecated public RubyArray constants19(ThreadContext context)
      Deprecated.
    • constants19

      @Deprecated public RubyArray constants19(ThreadContext context, IRubyObject allConstants)
      Deprecated.
    • constantsCommon19

      @Deprecated public RubyArray constantsCommon19(ThreadContext context, boolean replaceModule, boolean allConstants)
      Deprecated.
    • constantsCommon

      private RubyArray constantsCommon(ThreadContext context, boolean replaceModule, boolean allConstants)
    • constantsCommon

      public Collection<String> constantsCommon(Ruby runtime, boolean replaceModule, boolean allConstants)
      rb_mod_constants
    • constantsCommon

      public Collection<String> constantsCommon(Ruby runtime, boolean replaceModule, boolean allConstants, boolean includePrivate)
    • deprecateConstant

      public void deprecateConstant(Ruby runtime, String name)
    • deprecate_constant

      public IRubyObject deprecate_constant(ThreadContext context, IRubyObject name)
    • deprecate_constant

      public IRubyObject deprecate_constant(ThreadContext context, IRubyObject[] names)
    • private_constant

      public IRubyObject private_constant(ThreadContext context, IRubyObject name)
    • private_constant

      public IRubyObject private_constant(ThreadContext context, IRubyObject[] rubyNames)
    • public_constant

      public IRubyObject public_constant(ThreadContext context, IRubyObject name)
    • public_constant

      public IRubyObject public_constant(ThreadContext context, IRubyObject[] rubyNames)
    • prepend

      public IRubyObject prepend(ThreadContext context, IRubyObject[] modules)
    • prepended

      public IRubyObject prepended(ThreadContext context, IRubyObject other)
    • setConstantVisibility

      public final void setConstantVisibility(Ruby runtime, String name, boolean hidden)
    • setClassVar

      public IRubyObject setClassVar(String name, IRubyObject value)
      Set the named class variable to the given value, provided taint and freeze allow setting it. Ruby C equivalent = "rb_cvar_set"
      Parameters:
      name - The variable name to set
      value - The value to set it to
    • fastSetClassVar

      @Deprecated public IRubyObject fastSetClassVar(String internedName, IRubyObject value)
      Deprecated.
    • getClassVar

      public IRubyObject getClassVar(String name)
      Retrieve the specified class variable, searching through this module, included modules, and supermodules. Ruby C equivalent = "rb_cvar_get"
      Parameters:
      name - The name of the variable to retrieve
      Returns:
      The variable's value, or throws NameError if not found
    • getClassVar

      public IRubyObject getClassVar(IRubyObject nameObject, String name)
    • getClassVarQuiet

      public IRubyObject getClassVarQuiet(String name)
    • fastGetClassVar

      @Deprecated public IRubyObject fastGetClassVar(String internedName)
      Deprecated.
    • isClassVarDefined

      public boolean isClassVarDefined(String name)
      Is class var defined? Ruby C equivalent = "rb_cvar_defined"
      Parameters:
      name - The class var to determine "is defined?"
      Returns:
      true if true, false if false
    • fastIsClassVarDefined

      @Deprecated public boolean fastIsClassVarDefined(String internedName)
      Deprecated.
    • removeClassVariable

      public IRubyObject removeClassVariable(String name)
    • getConstantAtSpecial

      public IRubyObject getConstantAtSpecial(String name)
      This version searches superclasses if we're starting with Object. This corresponds to logic in rb_const_defined_0 that recurses for Object only.
      Parameters:
      name - the constant name to find
      Returns:
      the constant, or null if it was not found
    • getConstantAt

      public IRubyObject getConstantAt(String name)
    • getConstantAt

      public IRubyObject getConstantAt(String name, boolean includePrivate)
    • fastGetConstantAt

      @Deprecated public IRubyObject fastGetConstantAt(String internedName)
      Deprecated.
    • getConstant

      public IRubyObject getConstant(String name)
      Retrieve the named constant, invoking 'const_missing' should that be appropriate.
      Parameters:
      name - The constant to retrieve
      Returns:
      The value for the constant, or null if not found
    • getConstant

      public IRubyObject getConstant(String name, boolean inherit)
    • getConstant

      public IRubyObject getConstant(String name, boolean inherit, boolean includeObject)
    • fastGetConstant

      @Deprecated public IRubyObject fastGetConstant(String internedName)
      Deprecated.
    • fastGetConstant

      @Deprecated public IRubyObject fastGetConstant(String internedName, boolean inherit)
      Deprecated.
    • getConstantNoConstMissing

      public IRubyObject getConstantNoConstMissing(String name)
    • getConstantNoConstMissing

      public IRubyObject getConstantNoConstMissing(String name, boolean inherit)
    • getConstantNoConstMissing

      public IRubyObject getConstantNoConstMissing(String name, boolean inherit, boolean includeObject)
    • getConstantNoConstMissingSkipAutoload

      public final IRubyObject getConstantNoConstMissingSkipAutoload(String name)
    • getConstantNoConstMissingSKipAutoload

      @Deprecated public IRubyObject getConstantNoConstMissingSKipAutoload(String name)
      Deprecated.
    • getConstantSkipAutoload

      private IRubyObject getConstantSkipAutoload(String name, boolean inherit, boolean includeObject)
    • iterateConstantNoConstMissing

      private static IRubyObject iterateConstantNoConstMissing(String name, RubyModule init, boolean inherit, boolean loadConstant)
    • getConstantFrom

      public IRubyObject getConstantFrom(String name)
    • getConstantWithAutoload

      public IRubyObject getConstantWithAutoload(String name, IRubyObject failedAutoloadValue, boolean includePrivate)
      Search just this class for a constant value, or trigger autoloading.
      Parameters:
      name -
      Returns:
    • fastGetConstantFrom

      @Deprecated public IRubyObject fastGetConstantFrom(String internedName)
      Deprecated.
    • getConstantFromNoConstMissing

      public IRubyObject getConstantFromNoConstMissing(String name)
    • getConstantFromNoConstMissing

      public IRubyObject getConstantFromNoConstMissing(String name, boolean includePrivate)
    • fastGetConstantFromNoConstMissing

      @Deprecated public IRubyObject fastGetConstantFromNoConstMissing(String internedName)
      Deprecated.
    • getConstantFromConstMissing

      public IRubyObject getConstantFromConstMissing(String name)
    • fastGetConstantFromConstMissing

      @Deprecated public IRubyObject fastGetConstantFromConstMissing(String internedName)
      Deprecated.
    • resolveUndefConstant

      public final IRubyObject resolveUndefConstant(String name)
    • setConstantQuiet

      public IRubyObject setConstantQuiet(String name, IRubyObject value)
      Set the named constant on this module. Also, if the value provided is another Module and that module has not yet been named, assign it the specified name. This version does not warn if the constant has already been set.
      Parameters:
      name - The name to assign
      value - The value to assign to it; if an unnamed Module, also set its basename to name
      Returns:
      The result of setting the variable.
    • setConstant

      public IRubyObject setConstant(String name, IRubyObject value)
      Set the named constant on this module. Also, if the value provided is another Module and that module has not yet been named, assign it the specified name.
      Parameters:
      name - The name to assign
      value - The value to assign to it; if an unnamed Module, also set its basename to name
      Returns:
      The result of setting the variable.
    • setConstant

      public IRubyObject setConstant(String name, IRubyObject value, boolean hidden)
    • setConstantCommon

      private IRubyObject setConstantCommon(String name, IRubyObject value, boolean hidden, boolean warn)
      Set the named constant on this module. Also, if the value provided is another Module and that module has not yet been named, assign it the specified name.
      Parameters:
      name - The name to assign
      value - The value to assign to it; if an unnamed Module, also set its basename to name
      Returns:
      The result of setting the variable.
    • setParentForModule

      private void setParentForModule(String name, IRubyObject value)
    • fastSetConstant

      @Deprecated public IRubyObject fastSetConstant(String internedName, IRubyObject value)
      Deprecated.
    • defineConstant

      public void defineConstant(String name, IRubyObject value)
      rb_define_const
    • isConstantDefined

      public boolean isConstantDefined(String name, boolean inherit)
    • constDefined

      public boolean constDefined(String name)
    • constDefinedAt

      public boolean constDefinedAt(String name)
    • constDefinedFrom

      public boolean constDefinedFrom(String name)
    • publicConstDefinedFrom

      public boolean publicConstDefinedFrom(String name)
    • constDefinedInner

      private boolean constDefinedInner(String name, boolean exclude, boolean recurse, boolean visibility)
      rb_const_defined_0
    • autoloadingValue

      public boolean autoloadingValue(Ruby runtime, String name)
    • checkAutoloadRequired

      private RubyString checkAutoloadRequired(Ruby runtime, String name, String[] autoloadPath)
    • isConstantDefined

      public boolean isConstantDefined(String name)
    • cannotRemoveError

      private RaiseException cannotRemoveError(String id)
    • hasInternalModuleVariable

      public boolean hasInternalModuleVariable(String name)
      Behaves similarly to getClassVar(String). Searches this class/module and its ancestors for the specified internal variable.
      Parameters:
      name - the internal variable name
      Returns:
      the value of the specified internal variable if found, else null
      See Also:
    • searchInternalModuleVariable

      public IRubyObject searchInternalModuleVariable(String name)
      Behaves similarly to getClassVar(String). Searches this class/module and its ancestors for the specified internal variable.
      Parameters:
      name - the internal variable name
      Returns:
      the value of the specified internal variable if found, else null
      See Also:
    • setInternalModuleVariable

      public void setInternalModuleVariable(String name, IRubyObject value)
      Behaves similarly to setClassVar(String, IRubyObject). If the specified internal variable is found in this class/module or an ancestor, it is set where found. Otherwise it is set in this module.
      Parameters:
      name - the internal variable name
      value - the internal variable value
      See Also:
    • getClassVariables

      protected Map<String,IRubyObject> getClassVariables()
    • getClassVariablesForWriteSynchronized

      private Map<String,IRubyObject> getClassVariablesForWriteSynchronized()
      Get the class variables for write. If it is not set or not of the right size, synchronize against the object and prepare it accordingly.
      Returns:
      the class vars map, ready for assignment
    • getClassVariablesForWriteAtomic

      private Map<String,IRubyObject> getClassVariablesForWriteAtomic()
      Get the class variables for write. If it is not set or not of the right size, atomically update it with an appropriate value.
      Returns:
      the class vars map, ready for assignment
    • getClassVariablesForRead

      protected Map<String,IRubyObject> getClassVariablesForRead()
    • hasClassVariable

      public boolean hasClassVariable(String name)
    • fastHasClassVariable

      @Deprecated public boolean fastHasClassVariable(String internedName)
      Deprecated.
    • fetchClassVariable

      public IRubyObject fetchClassVariable(String name)
    • fastFetchClassVariable

      @Deprecated public IRubyObject fastFetchClassVariable(String internedName)
      Deprecated.
    • storeClassVariable

      public IRubyObject storeClassVariable(String name, IRubyObject value)
    • fastStoreClassVariable

      @Deprecated public IRubyObject fastStoreClassVariable(String internedName, IRubyObject value)
      Deprecated.
    • deleteClassVariable

      public IRubyObject deleteClassVariable(String name)
    • getClassVariableNameList

      public List<String> getClassVariableNameList()
    • validateClassVariable

      protected final String validateClassVariable(String name)
    • validateClassVariable

      protected final String validateClassVariable(IRubyObject nameObj, String name)
    • validateClassVariable

      protected String validateClassVariable(Ruby runtime, IRubyObject object)
    • ensureClassVariablesSettable

      protected final void ensureClassVariablesSettable()
    • hasConstant

      public boolean hasConstant(String name)
    • fastHasConstant

      @Deprecated public boolean fastHasConstant(String internedName)
      Deprecated.
    • fetchConstant

      public IRubyObject fetchConstant(String name)
    • fetchConstant

      public IRubyObject fetchConstant(String name, boolean includePrivate)
    • fastFetchConstant

      @Deprecated public IRubyObject fastFetchConstant(String internedName)
      Deprecated.
    • storeConstant

      public IRubyObject storeConstant(String name, IRubyObject value)
    • storeConstant

      public IRubyObject storeConstant(String name, IRubyObject value, boolean hidden)
    • storeConstant

      private IRubyObject storeConstant(String name, IRubyObject value, boolean hidden, boolean deprecated)
    • fastStoreConstant

      @Deprecated public IRubyObject fastStoreConstant(String internedName, IRubyObject value)
      Deprecated.
    • deleteConstant

      public IRubyObject deleteConstant(String name)
    • getStoredConstantList

      @Deprecated public List<Variable<IRubyObject>> getStoredConstantList()
      Deprecated.
    • getStoredConstantNameList

      @Deprecated public List<String> getStoredConstantNameList()
      Deprecated.
    • getConstantNames

      public Collection<String> getConstantNames()
      Returns:
      a list of constant names that exists at time this was called
    • getConstantNames

      public Collection<String> getConstantNames(boolean includePrivate)
    • validateConstant

      protected final String validateConstant(IRubyObject name)
      Validates name is a valid constant name and returns its id string.
      Parameters:
      name - object to verify as a valid constant.
      Returns:
      the id for this valid constant name.
    • validateConstant

      protected final String validateConstant(String name, IRubyObject errorName)
    • ensureConstantsSettable

      protected final void ensureConstantsSettable()
    • checkAndRaiseIfFrozen

      private void checkAndRaiseIfFrozen() throws RaiseException
      Throws:
      RaiseException
    • checkFrozen

      public final void checkFrozen()
      Description copied from class: RubyBasicObject
      The actual method that checks frozen with the default frozen message from MRI. If possible, call this instead of RubyBasicObject.testFrozen(java.lang.String).
      Overrides:
      checkFrozen in class RubyBasicObject
    • constantTableContains

      protected boolean constantTableContains(String name)
    • constantTableFetch

      protected IRubyObject constantTableFetch(String name)
    • constantEntryFetch

      protected RubyModule.ConstantEntry constantEntryFetch(String name)
    • constantTableStore

      protected IRubyObject constantTableStore(String name, IRubyObject value)
    • constantTableStore

      protected IRubyObject constantTableStore(String name, IRubyObject value, boolean hidden)
    • constantTableStore

      protected IRubyObject constantTableStore(String name, IRubyObject value, boolean hidden, boolean deprecated)
    • constantTableRemove

      protected IRubyObject constantTableRemove(String name)
    • defineAutoload

      protected final void defineAutoload(String symbol, RubyString path)
      Define an autoload. ConstantMap holds UNDEF for the name as an autoload marker.
    • finishAutoload

      protected final IRubyObject finishAutoload(String name)
      Extract an Object which is defined by autoload thread from autoloadMap and define it as a constant.
    • getAutoloadConstant

      public final IRubyObject getAutoloadConstant(String name)
      Get autoload constant. If it's first resolution for the constant, it tries to require the defined feature and returns the defined value. Multi-threaded accesses are blocked and processed sequentially except if the caller is the autoloading thread.
    • getAutoloadConstant

      protected IRubyObject getAutoloadConstant(String name, boolean loadConstant)
    • setAutoloadConstant

      private boolean setAutoloadConstant(String name, IRubyObject value)
      Set an Object as a defined constant in autoloading.
    • removeAutoload

      private void removeAutoload(String name)
      Removes an Autoload object from autoloadMap. ConstantMap must be updated before calling this.
    • getAutoloadFile

      protected RubyString getAutoloadFile(String name)
    • define

      private static void define(RubyModule module, JavaMethodDescriptor desc, String simpleName, DynamicMethod dynamicMethod)
    • initialize

      @Deprecated public IRubyObject initialize(Block block)
      Deprecated.
    • setJavaProxy

      public void setJavaProxy(boolean javaProxy)
      Set whether this class is associated with (i.e. a proxy for) a normal Java class or interface.
    • getJavaProxy

      public boolean getJavaProxy()
      Get whether this class is associated with (i.e. a proxy for) a normal Java class or interface.
    • getCacheProxy

      public boolean getCacheProxy()
      Get whether this Java proxy class should try to keep its instances idempotent and alive using the ObjectProxyCache.
    • setCacheProxy

      public void setCacheProxy(boolean cacheProxy)
      Set whether this Java proxy class should try to keep its instances idempotent and alive using the ObjectProxyCache.
    • toJava

      public <T> T toJava(Class<T> target)
      Description copied from interface: IRubyObject
      Convert the object to the specified Java class, if possible.
      Specified by:
      toJava in interface IRubyObject
      Overrides:
      toJava in class RubyBasicObject
      Parameters:
      target - The target type to which the object should be converted.
      See Also:
    • discoverInstanceVariables

      public Set<String> discoverInstanceVariables()
    • isRefinement

      public boolean isRefinement()
    • isIncludedIntoRefinement

      public boolean isIncludedIntoRefinement()
    • isMethodBuiltin

      public boolean isMethodBuiltin(String methodName)
      Return true if the given method is defined on this class and is a builtin (defined in Java at boot).
      Parameters:
      methodName -
      Returns:
    • getRefinements

      public Map<RubyModule,RubyModule> getRefinements()
    • getRefinementsForWrite

      public Map<RubyModule,RubyModule> getRefinementsForWrite()
    • setRefinements

      public void setRefinements(Map<RubyModule,RubyModule> refinements)
    • fastIsConstantDefined

      @Deprecated public boolean fastIsConstantDefined(String internedName)
      Deprecated.
    • fastIsConstantDefined19

      @Deprecated public boolean fastIsConstantDefined19(String internedName)
      Deprecated.
    • fastIsConstantDefined19

      @Deprecated public boolean fastIsConstantDefined19(String internedName, boolean inherit)
      Deprecated.
    • const_defined_p19

      @Deprecated public RubyBoolean const_defined_p19(ThreadContext context, IRubyObject[] args)
      Deprecated.
    • defineAliases

      @Deprecated public void defineAliases(List<String> aliases, String oldId)
      Deprecated.