Class FieldVariableAccessor

java.lang.Object
org.jruby.runtime.ivars.VariableAccessor
org.jruby.runtime.ivars.FieldVariableAccessor
Direct Known Subclasses:
RawFieldVariableAccessor

public class FieldVariableAccessor extends VariableAccessor
A variable accessor that accesses a field directly;
  • Constructor Details

    • FieldVariableAccessor

      public FieldVariableAccessor(RubyClass realClass, String name, int index, int classId, MethodHandle getter, MethodHandle setter)
      Construct a new FieldVariableAccessor for the given "real" class, variable name, variable index, class ID, and field offset
      Parameters:
      realClass - the "real" class
      name - the variable's name
      index - the variable's index
      classId - the class's ID
      getter - the getter handle for the field
      setter - the setter handle for the field
  • Method Details

    • wrapSetter

      protected MethodHandle wrapSetter(MethodHandle setter)
    • getGetter

      public MethodHandle getGetter()
    • getSetter

      public MethodHandle getSetter()
    • get

      public Object get(Object object)
      Retrieve the variable's value from the given object.
      Overrides:
      get in class VariableAccessor
      Parameters:
      object - the object from which to retrieve this variable
      Returns:
      the variable's value
    • getOrNil

      public IRubyObject getOrNil(Object object, ThreadContext context)
      Retrieve the variable's value from the given object.
      Overrides:
      getOrNil in class VariableAccessor
      Parameters:
      object - the object from which to retrieve this variable
      Returns:
      the variable's value
    • set

      public void set(Object object, Object value)
      Set this variable into the given object using Unsafe to ensure safe updating of the variable table.
      Overrides:
      set in class VariableAccessor
      Parameters:
      object - the object into which to set this variable
      value - the variable's value