org.jikesrvm.runtime
Class Reflection

java.lang.Object
  extended by org.jikesrvm.runtime.Reflection
All Implemented Interfaces:
Constants, HeapLayoutConstants, ThinLockConstants, TIBLayoutConstants, SizeConstants

public class Reflection
extends Object
implements Constants

Arch-independent portion of reflective method invoker.


Field Summary
static boolean bytecodeReflection
          Perform reflection using bytecodes (true) or out-of-line machine code (false)
static boolean cacheInvokerInJavaLangReflect
          Cache the reflective method invoker in JavaLangReflect?
private static byte[] emptyByteArray
           
private static double[] emptyDoubleArray
           
private static WordArray emptyWordArray
           
private static boolean firstUse
           
 
Fields inherited from interface org.jikesrvm.Constants
NOT_REACHED, REFLECTION_FPRS_BITS, REFLECTION_FPRS_MASK, REFLECTION_GPRS_BITS, REFLECTION_GPRS_MASK
 
Fields inherited from interface org.jikesrvm.objectmodel.ThinLockConstants
TL_DEDICATED_U16_OFFSET, TL_DEDICATED_U16_SHIFT, TL_LOCK_COUNT_MASK, TL_LOCK_COUNT_SHIFT, TL_LOCK_COUNT_UNIT, TL_LOCK_ID_MASK, TL_LOCK_ID_SHIFT, TL_NUM_BITS_RC, TL_NUM_BITS_STAT, TL_NUM_BITS_TID, TL_STAT_BIASABLE, TL_STAT_FAT, TL_STAT_MASK, TL_STAT_SHIFT, TL_STAT_THIN, TL_THREAD_ID_MASK, TL_THREAD_ID_SHIFT, TL_UNLOCK_MASK
 
Fields inherited from interface org.jikesrvm.SizeConstants
BITS_IN_ADDRESS, BITS_IN_BOOLEAN, BITS_IN_BYTE, BITS_IN_CHAR, BITS_IN_DOUBLE, BITS_IN_EXTENT, BITS_IN_FLOAT, BITS_IN_INT, BITS_IN_LONG, BITS_IN_OFFSET, BITS_IN_PAGE, BITS_IN_SHORT, BITS_IN_WORD, BYTES_IN_ADDRESS, BYTES_IN_BOOLEAN, BYTES_IN_BYTE, BYTES_IN_CHAR, BYTES_IN_DOUBLE, BYTES_IN_EXTENT, BYTES_IN_FLOAT, BYTES_IN_INT, BYTES_IN_LONG, BYTES_IN_OFFSET, BYTES_IN_PAGE, BYTES_IN_SHORT, BYTES_IN_WORD, LOG_BITS_IN_ADDRESS, LOG_BITS_IN_BOOLEAN, LOG_BITS_IN_BYTE, LOG_BITS_IN_CHAR, LOG_BITS_IN_DOUBLE, LOG_BITS_IN_EXTENT, LOG_BITS_IN_FLOAT, LOG_BITS_IN_INT, LOG_BITS_IN_LONG, LOG_BITS_IN_OFFSET, LOG_BITS_IN_PAGE, LOG_BITS_IN_SHORT, LOG_BITS_IN_WORD, LOG_BYTES_IN_ADDRESS, LOG_BYTES_IN_BOOLEAN, LOG_BYTES_IN_BYTE, LOG_BYTES_IN_CHAR, LOG_BYTES_IN_DOUBLE, LOG_BYTES_IN_EXTENT, LOG_BYTES_IN_FLOAT, LOG_BYTES_IN_INT, LOG_BYTES_IN_LONG, LOG_BYTES_IN_OFFSET, LOG_BYTES_IN_PAGE, LOG_BYTES_IN_SHORT, LOG_BYTES_IN_WORD
 
Fields inherited from interface org.jikesrvm.objectmodel.TIBLayoutConstants
IMT_METHOD_SLOTS, NEEDS_DYNAMIC_LINK, TIB_ARRAY_ELEMENT_TIB_INDEX, TIB_DOES_IMPLEMENT_INDEX, TIB_FIRST_SPECIALIZED_METHOD_INDEX, TIB_FIRST_VIRTUAL_METHOD_INDEX, TIB_INTERFACE_DISPATCH_TABLE_INDEX, TIB_SUPERCLASS_IDS_INDEX, TIB_TYPE_INDEX
 
Fields inherited from interface org.jikesrvm.HeapLayoutConstants
BAD_MAP_COMPRESSION, BOOT_IMAGE_CODE_END, BOOT_IMAGE_CODE_SIZE, BOOT_IMAGE_CODE_START, BOOT_IMAGE_DATA_END, BOOT_IMAGE_DATA_SIZE, BOOT_IMAGE_DATA_START, BOOT_IMAGE_END, BOOT_IMAGE_RMAP_END, BOOT_IMAGE_RMAP_START, MAX_BOOT_IMAGE_RMAP_SIZE, MAXIMUM_MAPPABLE
 
Constructor Summary
Reflection()
           
 
Method Summary
static Object invoke(RVMMethod method, ReflectionBase invoker, Object thisArg, Object[] otherArgs, boolean isNonvirtual)
          Call a method.
static boolean needsCheckArgs(ReflectionBase invoker)
          Does the reflective method scheme need to check the arguments are valid?
private static Object outOfLineInvoke(RVMMethod method, Object thisArg, Object[] otherArgs, boolean isNonvirtual)
           
static boolean unwrapBoolean(Object o)
           
static int unwrapBooleanAsInt(Object o)
           
static byte unwrapByte(Object o)
           
static char unwrapChar(Object o)
           
static double unwrapDouble(Object o)
           
static float unwrapFloat(Object o)
           
static int unwrapInt(Object o)
           
static long unwrapLong(Object o)
           
static Address unwrapObject(Object o)
           
static short unwrapShort(Object o)
           
static Object wrapBoolean(int b)
           
static Object wrapByte(byte b)
           
static Object wrapChar(char c)
           
static Object wrapDouble(double d)
           
static Object wrapFloat(float f)
           
static Object wrapInt(int i)
           
static Object wrapLong(long l)
           
static Object wrapShort(short s)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bytecodeReflection

public static boolean bytecodeReflection
Perform reflection using bytecodes (true) or out-of-line machine code (false)


cacheInvokerInJavaLangReflect

public static boolean cacheInvokerInJavaLangReflect
Cache the reflective method invoker in JavaLangReflect? If this is true and bytecodeReflection is false, then bytecode reflection will only be used for java.lang.reflect objects.


emptyWordArray

private static final WordArray emptyWordArray

emptyDoubleArray

private static final double[] emptyDoubleArray

emptyByteArray

private static final byte[] emptyByteArray

firstUse

private static boolean firstUse
Constructor Detail

Reflection

public Reflection()
Method Detail

needsCheckArgs

public static boolean needsCheckArgs(ReflectionBase invoker)
Does the reflective method scheme need to check the arguments are valid? Bytecode reflection doesn't need arguments checking as they are checking as they are unwrapped


invoke

public static Object invoke(RVMMethod method,
                            ReflectionBase invoker,
                            Object thisArg,
                            Object[] otherArgs,
                            boolean isNonvirtual)
Call a method.

Parameters:
method - method to be called
thisArg - "this" argument (ignored if method is static)
otherArgs - remaining arguments isNonvirtual flag is false if the method of the real class of this object is to be invoked; true if a method of a superclass may be invoked
Returns:
return value (wrapped if primitive) See also: java/lang/reflect/Method.invoke()

outOfLineInvoke

private static Object outOfLineInvoke(RVMMethod method,
                                      Object thisArg,
                                      Object[] otherArgs,
                                      boolean isNonvirtual)

wrapBoolean

public static Object wrapBoolean(int b)

wrapByte

public static Object wrapByte(byte b)

wrapChar

public static Object wrapChar(char c)

wrapShort

public static Object wrapShort(short s)

wrapInt

public static Object wrapInt(int i)

wrapLong

public static Object wrapLong(long l)

wrapFloat

public static Object wrapFloat(float f)

wrapDouble

public static Object wrapDouble(double d)

unwrapBooleanAsInt

public static int unwrapBooleanAsInt(Object o)

unwrapBoolean

public static boolean unwrapBoolean(Object o)

unwrapByte

public static byte unwrapByte(Object o)

unwrapChar

public static char unwrapChar(Object o)

unwrapShort

public static short unwrapShort(Object o)

unwrapInt

public static int unwrapInt(Object o)

unwrapLong

public static long unwrapLong(Object o)

unwrapFloat

public static float unwrapFloat(Object o)

unwrapDouble

public static double unwrapDouble(Object o)

unwrapObject

public static Address unwrapObject(Object o)