org.jruby
Class RubyClass

java.lang.Object
  extended by org.jruby.RubyObject
      extended by org.jruby.RubyModule
          extended by org.jruby.RubyClass
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, InstanceVariables, InternalVariables, IRubyObject, CoreObjectType
Direct Known Subclasses:
IncludedModuleWrapper, MetaClass

public class RubyClass
extends RubyModule

Author:
jpetersen
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jruby.RubyModule
RubyModule.ConstantTableEntry, RubyModule.KindOf, RubyModule.MethodClumper, RubyModule.ModuleKernelMethods
 
Nested classes/interfaces inherited from class org.jruby.RubyObject
RubyObject.Finalizer, RubyObject.ObjectMethods, RubyObject.VariableTableEntry
 
Field Summary
static ObjectAllocator CLASS_ALLOCATOR
           
protected static ObjectMarshal DEFAULT_OBJECT_MARSHAL
           
protected  ObjectMarshal marshal
           
 
Fields inherited from class org.jruby.RubyModule
classId, CONSTANT_TABLE_DEFAULT_CAPACITY, CONSTANT_TABLE_LOAD_FACTOR, CONSTANT_TABLE_MAXIMUM_CAPACITY, constantTable, constantTableSize, constantTableThreshold, dispatcher, ERR_FROZEN_CONST_TYPE, ERR_FROZEN_CVAR_TYPE, ERR_INSECURE_SET_CLASS_VAR, ERR_INSECURE_SET_CONSTANT, id, index, kindOf, parent, superClass, variableWriteLock
 
Fields inherited from class org.jruby.RubyObject
ALL_F, ERR_INSECURE_SET_INST_VAR, FALSE_F, FL_USHIFT, flags, FROZEN_F, metaClass, NEVER, NIL_F, OBJECT_ALLOCATOR, TAINTED_F, UNDEF, USER0_F, USER1_F, USER2_F, USER3_F, USER4_F, USER5_F, USER6_F, USER7_F, VARIABLE_TABLE_DEFAULT_CAPACITY, VARIABLE_TABLE_EMPTY_TABLE, VARIABLE_TABLE_LOAD_FACTOR, VARIABLE_TABLE_MAXIMUM_CAPACITY, variableTable, variableTableSize, variableTableThreshold
 
Fields inherited from interface org.jruby.runtime.builtin.IRubyObject
NULL_ARRAY
 
Constructor Summary
protected RubyClass(Ruby runtime)
          used by CLASS_ALLOCATOR (any Class' class will be a Class!) also used to bootstrap Object class
protected RubyClass(Ruby runtime, RubyClass superClazz)
          rb_class_boot (for plain Classes) also used to bootstrap Module and Class classes
protected RubyClass(Ruby runtime, RubyClass superClass, boolean objectSpace)
          separate path for MetaClass and IncludedModuleWrapper construction (rb_class_boot version for MetaClasses) no marshal, allocator initialization and addSubclass(this) here!
 
Method Summary
 void addSubclass(RubyClass subclass)
           
 IRubyObject allocate()
           
static void checkInheritable(IRubyObject superClass)
          rb_check_inheritable
static RubyClass createBootstrapClass(Ruby runtime, java.lang.String name, RubyClass superClass, ObjectAllocator allocator)
          boot_defclass Create an initial Object meta class before Module and Kernel dependencies have squirreled themselves together.
static void createClassClass(Ruby runtime, RubyClass classClass)
           
 ObjectAllocator getAllocator()
           
 Ruby getClassRuntime()
           
 ObjectMarshal getMarshal()
           
 int getNativeTypeIndex()
          This is overridden in the other concrete Java builtins to provide a fast way to determine what type they are.
 RubyClass getRealClass()
           
 void inherit(RubyClass superClazz)
          rb_class_inherited (reversed semantics!)
 IRubyObject inherited(ThreadContext context, IRubyObject arg)
           
 IRubyObject initialize_copy(IRubyObject original)
          rb_class_init_copy
 IRubyObject initialize(IRubyObject[] args, Block block)
          rb_class_initialize
 IRubyObject invoke(ThreadContext context, IRubyObject self, int methodIndex, java.lang.String name, IRubyObject[] args, CallType callType, Block block)
           
 IRubyObject invoke(ThreadContext context, IRubyObject self, java.lang.String name, IRubyObject[] args, CallType callType, Block block)
           
 IRubyObject invoke(ThreadContext context, IRubyObject self, java.lang.String name, IRubyObject arg, CallType callType, Block block)
           
 IRubyObject invokeInherited(ThreadContext context, IRubyObject self, IRubyObject subclass)
           
 boolean isClass()
          Specifically polymorphic method that are meant to be overridden by classes to specify that they are classes in an easy way.
 boolean isModule()
          Specifically polymorphic method that are meant to be overridden by modules to specify that they are modules in an easy way.
 boolean isSingleton()
           
 RubyClass makeMetaClass(RubyClass superClass)
          rb_make_metaclass
 void marshal(java.lang.Object obj, MarshalStream marshalStream)
           
static void marshalTo(RubyClass clazz, MarshalStream output)
           
static RubyClass newClass(Ruby runtime, RubyClass superClass)
          rb_class_new
static RubyClass newClass(Ruby runtime, RubyClass superClass, java.lang.String name, ObjectAllocator allocator, RubyModule parent, boolean setParent)
          rb_class_new/rb_define_class_id/rb_name_class/rb_set_class_path
 IRubyObject newInstance(ThreadContext context, IRubyObject[] args, Block block)
          rb_class_new_instance
 void setAllocator(ObjectAllocator allocator)
           
 void setMarshal(ObjectMarshal marshal)
           
 java.util.Collection subclasses(boolean includeDescendants)
           
 IRubyObject subclasses(ThreadContext context, IRubyObject[] args)
           
 IRubyObject superclass(ThreadContext context)
          Return the real super class of this class.
 java.lang.Object unmarshal(UnmarshalStream unmarshalStream)
           
static RubyClass unmarshalFrom(UnmarshalStream input)
           
 
Methods inherited from class org.jruby.RubyModule
addClassProvider, addMethod, addModuleFunction, alias_method, ancestors, ancestors, append_features, attr_accessor, attr_accessor, attr_reader, attr_reader, attr_writer, attr, class_variable_defined_p, class_variable_get, class_variable_set, class_variables, cloneMethods, const_defined_p, const_get, const_missing, const_set, constants, constantTableContains, constantTableFastContains, constantTableFastFetch, constantTableFastStore, constantTableFetch, constantTableGetMap, constantTableGetMap, constantTableGetSize, constantTableGetTable, constantTableRemove, constantTableStore, constantTableSync, createModuleClass, define_method, define_method, define_method, defineAlias, defineAliases, defineAnnotatedConstant, defineAnnotatedConstants, defineAnnotatedMethod, defineAnnotatedMethod, defineAnnotatedMethod, defineAnnotatedMethod, defineAnnotatedMethods, defineAnnotatedMethodsIndividually, defineClassUnder, defineConstant, defineFastMethod, defineFastMethod, defineFastModuleFunction, defineFastPrivateMethod, defineFastProtectedMethod, defineFastPublicModuleFunction, defineMethod, defineModuleFunction, defineModuleUnder, defineOrGetClassUnder, defineOrGetModuleUnder, definePrivateMethod, definePublicModuleFunction, deleteClassVariable, deleteConstant, ensureClassVariablesSettable, ensureConstantsSettable, executeUnder, exportMethod, extend_object, extended, fastFetchClassVariable, fastFetchConstant, fastGetClass, fastGetClassVar, fastGetConstant, fastGetConstantAt, fastGetConstantFrom, fastHasClassVariable, fastHasConstant, fastIsClassVarDefined, fastIsConstantDefined, fastSetClassVar, fastSetConstant, fastStoreClassVariable, fastStoreConstant, fetchClassVariable, fetchConstant, findImplementer, freeze, getAncestorList, getBaseName, getClass, getClassVar, getClassVariableList, getClassVariableNameList, getConstant, getConstantAt, getConstantFrom, getDispatcher, getMethods, getName, getNonIncludedClass, getParent, getStoredConstantList, getStoredConstantNameList, getSuperClass, getVariableCount, getVariableList, getVariableMap, getVariableNameList, hasClassVariable, hasConstant, hash, hashCode, hasInternalModuleVariable, hasModuleInHierarchy, hasVariables, include_p, include, included_modules, included, includeModule, initialize, instance_method, instance_methods, isClassVarDefined, isConstantDefined, isIncluded, isInstance, isKindOfModule, isMethodBound, isSame, marshalTo, method_added, method_defined_p, method_removed, method_undefined, module_eval, module_eval, module_eval, module_eval, module_eval, module_function, name, needsImplementer, nesting, newIncludeClass, newMethod, newModule, newModule, op_cmp, op_eqq, op_equal, op_ge, op_gt, op_le, op_lt, private_class_method, private_instance_methods, private_method_defined, protected_instance_methods, protected_method_defined, public_class_method, public_instance_methods, public_method_defined, rbPrivate, rbProtected, rbPublic, remove_class_variable, remove_const, remove_method, removeClassProvider, removeCvar, removeMethod, retrieveMethod, searchInternalModuleVariable, searchMethod, setBaseName, setClassVar, setConstant, setInternalModuleVariable, setMethodVisibility, setParent, setSuperClass, storeClassVariable, storeConstant, syncVariables, to_s, undef_method, undef, undefineMethod, validateClassVariable, validateConstant, variableTableFastStore, variableTableReadLocked, variableTableRemove, variableTableStore, variableTableSync
 
Methods inherited from class org.jruby.RubyObject
addFinalizer, anyToString, as, asJavaString, asString, attachToObjectSpace, callInit, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callSuper, checkArrayType, checkFrozen, checkStringType, convertToArray, convertToFloat, convertToHash, convertToInteger, convertToInteger, convertToString, convertToType, copySpecialInstanceVariables, createObjectClass, dataGetStruct, dataWrapStruct, display, dup, ensureInstanceVariablesSettable, eql_p, eql, eqlInternal, equal_p, equalInternal, equals, evalUnder, evalUnder, extend, fastGetInstanceVariable, fastGetInternalVariable, fastHasInstanceVariable, fastHasInternalVariable, fastSetInstanceVariable, fastSetInternalVariable, frozen_p, getFlag, getInstanceVariable, getInstanceVariableList, getInstanceVariableNameList, getInstanceVariables, getInternalVariable, getInternalVariableList, getInternalVariables, getJavaClass, getMetaClass, getRuntime, getSingletonClass, getSingletonClassClone, getType, hasInstanceVariable, hasInternalVariable, id_deprecated, id, infectBy, initialize, inspect, instance_eval, instance_eval, instance_eval, instance_eval, instance_eval, instance_exec, instance_of_p, instance_variable_defined_p, instance_variable_get, instance_variable_set, instance_variables, isFalse, isFrozen, isImmediate, isNil, isRubyVariable, isTaint, isTrue, kind_of_p, method, methods, nil_p, op_match, private_methods, protected_methods, public_methods, puts, rbClone, remove_instance_variable, removeFinalizers, removeInstanceVariable, removeInternalVariable, respond_to_p, respond_to_p, respondsTo, send, setFlag, setFrozen, setInstanceVariable, setInternalVariable, setMetaClass, setTaint, singleton_methods, specificEval, specificEval, specificEval, specificEval, specificEval, taint, tainted_p, testFrozen, to_a, to_java, toString, type_deprecated, type, untaint, validateInstanceVariable, variableTableContains, variableTableFastContains, variableTableFastFetch, variableTableFetch, variableTableGetMap, variableTableGetMap, variableTableGetSize, variableTableGetTable, variableTableRehash
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

CLASS_ALLOCATOR

public static final ObjectAllocator CLASS_ALLOCATOR

marshal

protected ObjectMarshal marshal

DEFAULT_OBJECT_MARSHAL

protected static final ObjectMarshal DEFAULT_OBJECT_MARSHAL
Constructor Detail

RubyClass

protected RubyClass(Ruby runtime,
                    RubyClass superClass,
                    boolean objectSpace)
separate path for MetaClass and IncludedModuleWrapper construction (rb_class_boot version for MetaClasses) no marshal, allocator initialization and addSubclass(this) here!


RubyClass

protected RubyClass(Ruby runtime)
used by CLASS_ALLOCATOR (any Class' class will be a Class!) also used to bootstrap Object class


RubyClass

protected RubyClass(Ruby runtime,
                    RubyClass superClazz)
rb_class_boot (for plain Classes) also used to bootstrap Module and Class classes

Method Detail

createClassClass

public static void createClassClass(Ruby runtime,
                                    RubyClass classClass)

getAllocator

public ObjectAllocator getAllocator()

setAllocator

public void setAllocator(ObjectAllocator allocator)

allocate

public IRubyObject allocate()

getNativeTypeIndex

public int getNativeTypeIndex()
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:
getNativeTypeIndex in interface CoreObjectType
Overrides:
getNativeTypeIndex in class RubyModule
Returns:
the ClassIndex of the native type this object was constructed from
See Also:
org.jruby.runtime.ClassInde

isModule

public boolean isModule()
Description copied from class: RubyObject
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 RubyModule
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: RubyObject
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 RubyModule
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()
Overrides:
isSingleton in class RubyModule

createBootstrapClass

public static RubyClass createBootstrapClass(Ruby runtime,
                                             java.lang.String name,
                                             RubyClass superClass,
                                             ObjectAllocator allocator)
boot_defclass Create an initial Object meta class before Module and Kernel dependencies have squirreled themselves together.

Parameters:
runtime - we need it
Returns:
a half-baked meta class for object

newClass

public static RubyClass newClass(Ruby runtime,
                                 RubyClass superClass)
rb_class_new


newClass

public static RubyClass newClass(Ruby runtime,
                                 RubyClass superClass,
                                 java.lang.String name,
                                 ObjectAllocator allocator,
                                 RubyModule parent,
                                 boolean setParent)
rb_class_new/rb_define_class_id/rb_name_class/rb_set_class_path


makeMetaClass

public RubyClass makeMetaClass(RubyClass superClass)
rb_make_metaclass

Overrides:
makeMetaClass in class RubyObject

invoke

public IRubyObject invoke(ThreadContext context,
                          IRubyObject self,
                          int methodIndex,
                          java.lang.String name,
                          IRubyObject[] args,
                          CallType callType,
                          Block block)

invoke

public IRubyObject invoke(ThreadContext context,
                          IRubyObject self,
                          java.lang.String name,
                          IRubyObject[] args,
                          CallType callType,
                          Block block)

invoke

public IRubyObject invoke(ThreadContext context,
                          IRubyObject self,
                          java.lang.String name,
                          IRubyObject arg,
                          CallType callType,
                          Block block)

invokeInherited

public IRubyObject invokeInherited(ThreadContext context,
                                   IRubyObject self,
                                   IRubyObject subclass)

newInstance

public IRubyObject newInstance(ThreadContext context,
                               IRubyObject[] args,
                               Block block)
rb_class_new_instance


initialize

public IRubyObject initialize(IRubyObject[] args,
                              Block block)
rb_class_initialize


initialize_copy

public IRubyObject initialize_copy(IRubyObject original)
rb_class_init_copy

Overrides:
initialize_copy in class RubyModule

subclasses

public IRubyObject subclasses(ThreadContext context,
                              IRubyObject[] args)

subclasses

public java.util.Collection subclasses(boolean includeDescendants)

addSubclass

public void addSubclass(RubyClass subclass)

getClassRuntime

public Ruby getClassRuntime()

getRealClass

public RubyClass getRealClass()

inherited

public IRubyObject inherited(ThreadContext context,
                             IRubyObject arg)

inherit

public void inherit(RubyClass superClazz)
rb_class_inherited (reversed semantics!)


superclass

public IRubyObject superclass(ThreadContext context)
Return the real super class of this class. rb_class_superclass


checkInheritable

public static void checkInheritable(IRubyObject superClass)
rb_check_inheritable


getMarshal

public final ObjectMarshal getMarshal()

setMarshal

public final void setMarshal(ObjectMarshal marshal)

marshal

public final void marshal(java.lang.Object obj,
                          MarshalStream marshalStream)
                   throws java.io.IOException
Throws:
java.io.IOException

unmarshal

public final java.lang.Object unmarshal(UnmarshalStream unmarshalStream)
                                 throws java.io.IOException
Throws:
java.io.IOException

marshalTo

public static void marshalTo(RubyClass clazz,
                             MarshalStream output)
                      throws java.io.IOException
Throws:
java.io.IOException

unmarshalFrom

public static RubyClass unmarshalFrom(UnmarshalStream input)
                               throws java.io.IOException
Throws:
java.io.IOException


Copyright © 2002-2007 JRuby Team. All Rights Reserved.