Package org.jruby
Class RubyObject
java.lang.Object
org.jruby.RubyBasicObject
org.jruby.RubyObject
- All Implemented Interfaces:
Serializable
,Cloneable
,Comparable<IRubyObject>
,InstanceVariables
,InternalVariables
,IRubyObject
,CoreObjectType
- Direct Known Subclasses:
AbstractRubyMethod
,Addrinfo
,ArrayJavaProxyCreator
,ConditionVariable
,DynamicLibrary
,Enums
,Ifaddr
,JavaObject
,JavaProxy
,JavaProxyReflectionObject
,JRubyExecutionContextLocal
,JRubyObjectInputStream
,MemoryObject
,Monitor
,Mutex
,Option
,Queue
,RubyArgsFile
,RubyArithmeticSequence
,RubyArray
,RubyBinding
,RubyBoolean
,RubyChain
,RubyClassPathVariable
,RubyContinuation
,RubyConverter
,RubyDate
,RubyDigest.DigestBase
,RubyDigest.DigestClass
,RubyDir
,RubyEncoding
,RubyEnumerator
,RubyEnumerator.FeedValue
,RubyException
,RubyFileStat
,RubyGenerator
,RubyGzipFile
,RubyHash
,RubyIO
,RubyIOBuffer
,RubyMatchData
,RubyModule
,RubyNameError.RubyNameErrorMessage
,RubyNil
,RubyNumeric
,RubyObject.Data
,RubyObjectSpace.AbstractWeakMap
,RubyPathname
,RubyProc
,RubyProcess.RubyStatus
,RubyProducer
,RubyRandomBase
,RubyRange
,RubyRegexp
,RubyRipper
,RubySet
,RubyString
,RubyStruct
,RubySymbol
,RubySyslog
,RubyThread
,RubyThread.Backtrace
,RubyThread.Location
,RubyThreadGroup
,RubyTime
,RubyYielder
,StructLayout.ArrayProxy
,StructLayout.Field
,ThreadFiber
,TracePoint
,Type
,VariadicInvoker
,ZStream
RubyObject represents the implementation of the Object class in Ruby. As such,
it defines very few methods of its own, inheriting most from the included
Kernel module.
Methods that are implemented here, such as "initialize" should be implemented
with care; reification of Ruby classes into Java classes can produce
conflicting method names in rare cases. See JRUBY-5906 for an example.
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.jruby.RubyBasicObject
RubyBasicObject.Finalizer
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ObjectAllocator
Allocator that inspects all methods for instance variables and chooses a concrete class to construct based on that.static final ObjectAllocator
Default allocator instance for all Ruby objects.static final ObjectAllocator
Fields inherited from class org.jruby.RubyBasicObject
ALL_F, BASICOBJECT_ALLOCATOR, COMPARE_BY_IDENTITY_F, ERR_INSECURE_SET_INST_VAR, FALSE_F, FL_USHIFT, flags, FROZEN_F, IS_OVERLAID_F, metaClass, NEVER, NIL_F, REFINED_MODULE_F, STAMP_OFFSET, TAINTED_F, UNDEF, USER0_F, USER1_F, USER2_F, USER3_F, USER4_F, USER5_F, USER6_F, USER7_F, USER8_F, USER9_F, USERA_F, VAR_TABLE_OFFSET, varTable, varTableStamp
Fields inherited from interface org.jruby.runtime.builtin.IRubyObject
NULL_ARRAY
-
Constructor Summary
ConstructorsModifierConstructorDescriptionRubyObject
(RubyClass metaClass) Path for objects that don't enter objectspace.RubyObject
(Ruby runtime, RubyClass metaClass) Standard path for object creation.protected
RubyObject
(Ruby runtime, RubyClass metaClass, boolean useObjectSpace) Path for objects who want to decide whether they don't want to be in ObjectSpace even when it is on.protected
RubyObject
(Ruby runtime, RubyClass metaClass, boolean useObjectSpace, boolean canBeTainted) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Will make sure that this object is added to the current object space.final void
Call the Ruby initialize method with the supplied arguments and block.final void
callInit
(IRubyObject[] args, Block block) Call the Ruby initialize method with the supplied arguments and block.final void
callInit
(IRubyObject arg0, Block block) Call the Ruby initialize method with the supplied arguments and block.final void
callInit
(IRubyObject arg0, IRubyObject arg1, Block block) Call the Ruby initialize method with the supplied arguments and block.final void
callInit
(IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block block) final void
callInit
(ThreadContext context, Block block) final void
callInit
(ThreadContext context, IRubyObject[] args, Block block) final void
callInit
(ThreadContext context, IRubyObject arg0, Block block) final void
callInit
(ThreadContext context, IRubyObject arg0, IRubyObject arg1, Block block) final void
callInit
(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block block) final IRubyObject
convertToType
(RubyClass target, int convertMethodIndex) Deprecated.static IRubyObject
dig
(ThreadContext context, IRubyObject obj, IRubyObject[] args, int idx) static IRubyObject
dig1
(ThreadContext context, IRubyObject obj, IRubyObject arg1) static IRubyObject
dig2
(ThreadContext context, IRubyObject obj, IRubyObject arg1, IRubyObject arg2) protected static boolean
eqlInternal
(ThreadContext context, IRubyObject a, IRubyObject b) Helper method for checking equality, first using Java identity equality, and then calling the "eql?" method.static boolean
equalInternal
(ThreadContext context, IRubyObject a, IRubyObject b) Helper method for checking equality, first using Java identity equality, and then calling the "==" method.boolean
This override does not do a "checked" dispatch.static void
finishObjectClass
(RubyClass Object) Will create the Ruby class Object in the runtime specified.This is overridden in the other concrete Java builtins to provide a fast way to determine what type they are.int
hashCode()
This override does not do "checked" dispatch since Object usually has #hash defined.static RubyString
inspect
(ThreadContext context, IRubyObject object) rb_inspect The internal helper that ensures a RubyString instance is returned so dangerous casting can be omitted Preferred over callMethod(context, "inspect")op_eqq
(ThreadContext context, IRubyObject other) rb_equal The Ruby "===" method is used by default in case/when statements.static void
Deprecated.no longer used - uses Java's System.outspecificEval
(ThreadContext context, RubyModule mod, IRubyObject[] args, Block block, EvalType evalType) Deprecated.toRubyString
(ThreadContext context) The default toString method is just a wrapper that calls the Ruby "to_s" method.toString()
The default toString method is just a wrapper that calls the Ruby "to_s" method.Methods inherited from class org.jruby.RubyBasicObject
addFinalizer, addFinalizer, anyToString, asJavaString, asString, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callSuper, checkArrayType, checkCallMethod, checkCallMethod, checkFrozen, checkStringType, cloneSetup, compareTo, convertToArray, convertToFloat, convertToHash, convertToInteger, convertToInteger, convertToInteger, convertToString, copyInstanceVariablesInto, copySpecialInstanceVariables, dataGetStruct, dataGetStructChecked, dataWrapStruct, decode, display, dup, dupFinalizer, dupSetup, ensureInstanceVariablesSettable, eql, eql_p, eql_p, equal_p, evalUnder, extend, fastGetInstanceVariable, fastGetInternalVariable, fastHasInstanceVariable, fastHasInternalVariable, fastSetInstanceVariable, fastSetInternalVariable, finishBasicObjectClass, forEachInstanceVariable, forEachInstanceVariableName, freeze, frozen_p, getCurrentContext, getFFIHandle, getFlag, getInstanceEvalClass, getInstanceEvalClass, getInstanceVariable, getInstanceVariableList, getInstanceVariableNameList, getInstanceVariables, getInternalVariable, getInternalVariables, getJavaClass, getMarshalVariableList, getMetaClass, getMetaClass, getNativeHandle, getNativeTypeIndex, getObjectId, getRuntime, getSingletonClass, getSingletonClassClone, getSingletonClassCloneAndAttach, getSingletonClassCloneAndAttach, getType, getVariable, getVariableCount, getVariableList, getVariableNameList, hash, hash, hashyInspect, hasInstanceVariable, hasInstanceVariables, hasInternalVariable, hasVariables, id, infectBy, initialize, initialize_copy, initialize_copy, inspect, inspect, inspectHashCode, 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, isBuiltin, isClass, isFalse, isFrozen, isImmediate, isModule, isNil, isSpecialConst, isSpecialObject, isTaint, isTrue, isUntrusted, kind_of_p, makeMetaClass, makeMetaClass, makeMetaClassBootstrap, method, method, method, method_missing, methods, methods, nil_p, nonFixnumHashCode, nonFixnumHashCode, OBJ_INIT_COPY, objInitCopy, op_cmp, op_equal, op_match, op_not, op_not_equal, op_not_match, private_methods, protected_methods, public_methods, rbClone, rbClone, rbInspect, remove_instance_variable, removeFinalizers, removeInstanceVariable, removeInternalVariable, respond_to_p, respond_to_p, respondsTo, respondsToMissing, respondsToMissing, send, send, send, send, send, setFFIHandle, setFlag, setFrozen, setInstanceVariable, setInternalVariable, setMetaClass, setNativeHandle, setTaint, setUntrusted, setVariable, singleton_method, singleton_method, singleton_method_added, singleton_method_removed, singleton_method_undefined, singleton_methods, singletonClass, specificEval, specificEval, specificEval, specificEval, syncVariables, syncVariables, taint, taint, tainted_p, testFrozen, testFrozen, to_a, to_a, to_s, to_s, toJava, trust, type, untaint, untrust, untrusted_p, validateInstanceVariable, validateInstanceVariable, validateInstanceVariable, variableTableContains, variableTableFastContains, variableTableFastFetch, variableTableFastStore, variableTableFetch, variableTableRemove, variableTableStore, variableTableSync, yieldUnder, yieldUnder
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.jruby.runtime.builtin.IRubyObject
checkStringType19, dup, marshalLiveVariables
-
Field Details
-
OBJECT_ALLOCATOR
Default allocator instance for all Ruby objects. The only reason to not use this allocator is if you actually need to have all instances of something be a subclass of RubyObject.- See Also:
-
IVAR_INSPECTING_OBJECT_ALLOCATOR
Allocator that inspects all methods for instance variables and chooses a concrete class to construct based on that. This allows using specialized subclasses to hold instance variables in fields rather than always holding them in an array. -
REIFYING_OBJECT_ALLOCATOR
-
-
Constructor Details
-
RubyObject
Standard path for object creation. Objects are entered into ObjectSpace only if ObjectSpace is enabled.- Parameters:
runtime
- the runtimemetaClass
- the metaclass
-
RubyObject
Path for objects that don't enter objectspace.- Parameters:
metaClass
- the metaclass
-
RubyObject
@Deprecated protected RubyObject(Ruby runtime, RubyClass metaClass, boolean useObjectSpace, boolean canBeTainted) Deprecated. -
RubyObject
Path for objects who want to decide whether they don't want to be in ObjectSpace even when it is on. (notably used by objects being considered immediate, they'll always pass false here)- Parameters:
runtime
- the runtimemetaClass
- the metaclassuseObjectSpace
- to enable object space
-
-
Method Details
-
finishObjectClass
Will create the Ruby class Object in the runtime specified. This method needs to take the actual class as an argument because of the Object class' central part in runtime initialization.- Parameters:
Object
- the object claass
-
attachToObjectSpace
public void attachToObjectSpace()Will make sure that this object is added to the current object space.- See Also:
-
getNativeClassIndex
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 interfaceCoreObjectType
- Overrides:
getNativeClassIndex
in classRubyBasicObject
- Returns:
- the ClassIndex of the native type this object was constructed from
- See Also:
-
puts
Deprecated.no longer used - uses Java's System.outSimple helper to print any objects.- Parameters:
obj
- to puts
-
equals
This override does not do a "checked" dispatch.- Overrides:
equals
in classRubyBasicObject
- Parameters:
other
- object to compare- Returns:
- true if equals
- See Also:
-
toRubyString
The default toString method is just a wrapper that calls the Ruby "to_s" method. This will raise if it is not actually a Ruby String.- Parameters:
context
- thread context this is executing on.- Returns:
- the string.
-
toString
The default toString method is just a wrapper that calls the Ruby "to_s" method. -
callInit
Call the Ruby initialize method with the supplied arguments and block.- Parameters:
args
- argsblock
- block
-
callInit
Call the Ruby initialize method with the supplied arguments and block.- Parameters:
block
- block
-
callInit
Call the Ruby initialize method with the supplied arguments and block.- Parameters:
arg0
- arg0block
- block
-
callInit
Call the Ruby initialize method with the supplied arguments and block.- Parameters:
arg0
- arg0arg1
- arg1block
- block
-
callInit
-
callInit
-
callInit
-
callInit
-
callInit
-
callInit
public final void callInit(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block block) -
convertToType
Deprecated. -
specificEval
@Deprecated public IRubyObject specificEval(ThreadContext context, RubyModule mod, IRubyObject[] args, Block block, EvalType evalType) Deprecated. -
op_eqq
rb_equal The Ruby "===" method is used by default in case/when statements. The Object implementation first checks Java identity equality and then calls the "==" method too.- Specified by:
op_eqq
in interfaceIRubyObject
- Overrides:
op_eqq
in classRubyBasicObject
-
equalInternal
Helper method for checking equality, first using Java identity equality, and then calling the "==" method.- Parameters:
context
- the thread contexta
- first comparatorb
- second comparator- Returns:
- true if equal
-
eqlInternal
Helper method for checking equality, first using Java identity equality, and then calling the "eql?" method.- Parameters:
context
- the thread contexta
- first comparatorb
- second comparator- Returns:
- true if eql
-
hashCode
public int hashCode()This override does not do "checked" dispatch since Object usually has #hash defined.- Overrides:
hashCode
in classRubyBasicObject
- Returns:
- the hash code
- See Also:
-
inspect
rb_inspect The internal helper that ensures a RubyString instance is returned so dangerous casting can be omitted Preferred over callMethod(context, "inspect")- Parameters:
context
- the thread contextobject
- the object to inspect- Returns:
- the string
-
dig
-
dig1
-
dig2
public static IRubyObject dig2(ThreadContext context, IRubyObject obj, IRubyObject arg1, IRubyObject arg2)
-