public class RubyObject extends RubyBasicObject
IRubyObject
. Every Ruby object in JRuby
is represented by something that is an instance of RubyObject. In
some of the core class implementations, this means doing a subclass
that extends RubyObject, in other cases it means using a simple
RubyObject instance and the data field to store specific
information about the Ruby object.
Some care has been taken to make the implementation be as
monomorphic as possible, so that the Java Hotspot engine can
improve performance of it. That is the reason for several patterns
that might seem odd in this class.
The IRubyObject interface used to have lots of methods for
different things, but these have now mostly been refactored into
several interfaces that gives access to that specific part of the
object. This gives us the possibility to switch out that subsystem
without changing interfaces again. For example, instance variable
and internal variables are handled this way, but the implementation
in RubyObject only returns "this" in RubyBasicObject.getInstanceVariables()
and
RubyBasicObject.getInternalVariables()
.Modifier and Type | Class and Description |
---|---|
static class |
RubyObject.Data |
RubyBasicObject.Finalizer
Modifier and Type | Field and Description |
---|---|
static ObjectAllocator |
OBJECT_ALLOCATOR
Default allocator instance for all Ruby objects.
|
static ObjectAllocator |
REIFYING_OBJECT_ALLOCATOR |
ALL_F, BASICOBJECT_ALLOCATOR, COMPARE_BY_IDENTITY_F, ERR_INSECURE_SET_INST_VAR, FALSE_F, FL_USHIFT, flags, FROZEN_F, metaClass, NEVER, NIL_F, TAINTED_F, UNDEF, UNTRUSTED_F, USER0_F, USER1_F, USER2_F, USER3_F, USER4_F, USER5_F, USER6_F, USER7_F, USER8_F
NULL_ARRAY
Modifier | Constructor and Description |
---|---|
|
RubyObject(RubyClass metaClass)
Path for objects that don't taint and don't enter objectspace.
|
|
RubyObject(Ruby runtime,
RubyClass metaClass)
Standard path for object creation.
|
protected |
RubyObject(Ruby runtime,
RubyClass metaClass,
boolean useObjectSpace) |
protected |
RubyObject(Ruby runtime,
RubyClass metaClass,
boolean useObjectSpace,
boolean canBeTainted)
Path for objects who want to decide whether they don't want to be in
ObjectSpace even when it is on.
|
Modifier and Type | Method and Description |
---|---|
void |
attachToObjectSpace()
Will make sure that this object is added to the current object
space.
|
void |
callInit(Block block)
Call the Ruby initialize method with the supplied arguments and block.
|
void |
callInit(IRubyObject[] args,
Block block)
Call the Ruby initialize method with the supplied arguments and block.
|
void |
callInit(IRubyObject arg0,
Block block)
Call the Ruby initialize method with the supplied arguments and block.
|
void |
callInit(IRubyObject arg0,
IRubyObject arg1,
Block block)
Call the Ruby initialize method with the supplied arguments and block.
|
void |
callInit(IRubyObject arg0,
IRubyObject arg1,
IRubyObject arg2,
Block block)
Call the Ruby initialize method with the supplied arguments and block.
|
IRubyObject |
convertToType(RubyClass target,
int convertMethodIndex)
Deprecated.
|
static RubyClass |
createObjectClass(Ruby runtime,
RubyClass objectClass)
Will create the Ruby class Object in the runtime
specified.
|
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.
|
protected 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 |
equals(java.lang.Object other)
This method is just a wrapper around the Ruby "==" method,
provided so that RubyObjects can be used as keys in the Java
HashMap object underlying RubyHash.
|
int |
getNativeTypeIndex()
This is overridden in the other concrete Java builtins to provide a fast way
to determine what type they are.
|
int |
hashCode()
Override the Object#hashCode method to make sure that the Ruby
hash is actually used as the hashcode for Ruby objects.
|
IRubyObject |
initialize() |
IRubyObject |
op_eqq(ThreadContext context,
IRubyObject other)
rb_equal
The Ruby "===" method is used by default in case/when
statements.
|
static void |
puts(java.lang.Object obj)
Simple helper to print any objects.
|
IRubyObject |
specificEval(ThreadContext context,
RubyModule mod,
IRubyObject[] args,
Block block)
Deprecated.
|
java.lang.String |
toString()
The default toString method is just a wrapper that calls the
Ruby "to_s" method.
|
addFinalizer, anyToString, asJavaString, asString, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callSuper, checkArrayType, checkCallMethod, checkFrozen, checkStringType, checkStringType19, compareTo, convertToArray, convertToFloat, convertToHash, convertToInteger, convertToInteger, convertToInteger, convertToString, copyInstanceVariablesInto, copySpecialInstanceVariables, createBasicObjectClass, dataGetStruct, dataGetStructChecked, dataWrapStruct, display, dup, ensureInstanceVariablesSettable, eql_p, eql, equal_p, equal_p19, evalUnder, extend, fastGetInstanceVariable, fastGetInternalVariable, fastHasInstanceVariable, fastHasInternalVariable, fastSetInstanceVariable, fastSetInternalVariable, freeze, frozen_p, getFlag, getInstanceEvalClass, getInstanceVariable, getInstanceVariableList, getInstanceVariableNameList, getInstanceVariables, getInternalVariable, getInternalVariables, getJavaClass, getMetaClass, getObjectId, getRuntime, getSingletonClass, getSingletonClassClone, getType, getVariable, getVariableCount, getVariableList, getVariableNameList, hash, hashyInspect, hasInstanceVariable, hasInternalVariable, hasVariables, id_deprecated, id, infectBy, initialize_copy, initialize19, initialize19, initialize19, initialize19, initialize19, initObjectId, inspect, inspectHashCode, instance_eval, instance_eval, instance_eval, instance_eval, instance_eval19, instance_eval19, instance_eval19, instance_eval19, instance_exec, instance_exec19, instance_of_p, instance_variable_defined_p, instance_variable_get, instance_variable_set, instance_variables, instance_variables19, isBuiltin, isClass, isFalse, isFrozen, isImmediate, isModule, isNil, isTaint, isTrue, isUntrusted, kind_of_p, makeMetaClass, method_missing19, method, method19, methods, methods, methods19, nil_p, op_cmp, op_equal_19, op_equal, op_match, op_match19, op_not_equal, op_not_match, op_not, private_methods, private_methods19, protected_methods, protected_methods19, public_methods, public_methods19, rbClone, remove_instance_variable, removeFinalizers, removeInstanceVariable, removeInternalVariable, respond_to_p, respond_to_p, respond_to_p19, respond_to_p19, respondsTo, respondsToMissing, respondsToMissing, send, send, send, send, send, send19, send19, send19, send19, send19, setFlag, setFrozen, setInstanceVariable, setInternalVariable, setMetaClass, setTaint, setUntrusted, setVariable, singleton_method_added19, singleton_method_removed19, singleton_method_undefined19, singleton_methods, singleton_methods19, specificEval, specificEval, specificEval, specificEval, syncVariables, syncVariables, taint, taint, tainted_p, testFrozen, testFrozen, to_a, to_s, toJava, trust, type_deprecated, type, untaint, untrust, untrusted_p, validateInstanceVariable, variableTableContains, variableTableFastContains, variableTableFastFetch, variableTableFastStore, variableTableFetch, variableTableRemove, variableTableStore, variableTableSync, yieldUnder, yieldUnder
public static final ObjectAllocator OBJECT_ALLOCATOR
ObjectAllocator
public static final ObjectAllocator REIFYING_OBJECT_ALLOCATOR
public RubyObject(Ruby runtime, RubyClass metaClass)
public RubyObject(RubyClass metaClass)
protected RubyObject(Ruby runtime, RubyClass metaClass, boolean useObjectSpace, boolean canBeTainted)
public static RubyClass createObjectClass(Ruby runtime, RubyClass objectClass)
public IRubyObject initialize()
initialize
in class RubyBasicObject
public void attachToObjectSpace()
ObjectSpace
public int getNativeTypeIndex()
getNativeTypeIndex
in interface CoreObjectType
getNativeTypeIndex
in class RubyBasicObject
org.jruby.runtime.ClassInde
public static void puts(java.lang.Object obj)
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public final void callInit(IRubyObject[] args, Block block)
public final void callInit(Block block)
public final void callInit(IRubyObject arg0, Block block)
public final void callInit(IRubyObject arg0, IRubyObject arg1, Block block)
public final void callInit(IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block block)
@Deprecated public final IRubyObject convertToType(RubyClass target, int convertMethodIndex)
@Deprecated public IRubyObject specificEval(ThreadContext context, RubyModule mod, IRubyObject[] args, Block block)
public IRubyObject op_eqq(ThreadContext context, IRubyObject other)
op_eqq
in interface IRubyObject
op_eqq
in class RubyBasicObject
protected static boolean equalInternal(ThreadContext context, IRubyObject a, IRubyObject b)
protected static boolean eqlInternal(ThreadContext context, IRubyObject a, IRubyObject b)
public int hashCode()
hashCode
in class java.lang.Object
Copyright © 2002-2009 JRuby Team. All Rights Reserved.