Search in sources :

Example 6 with RVMField

use of org.jikesrvm.classloader.RVMField in project JikesRVM by JikesRVM.

the class JNIFunctions method ToReflectedField.

/**
 * ToReflectedField
 * @param env A JREF index for the JNI environment object
 * @param clsJREF The JREF index of the class from which fieldID was
 * derived.
 * @param fieldID a jfieldID
 * @param isStatic argument that is not specified in Sun's JNI 1.2 spec,
 *            but IS present in the 1.4.2 JDK's implementation!  Our
 *            implementation will just ignore it, in any case.  This is a
 *            good example of why the same entity
 *            shouldn't get to write both the spec and the reference
 *            implementation.
 * @return a JREF index for the java.lang.reflect.Field object associated
 *         with fieldID.
 */
private static int ToReflectedField(JNIEnvironment env, int clsJREF, int fieldID, boolean isStatic) {
    if (traceJNI)
        VM.sysWriteln("JNI called: ToReflectedField");
    RuntimeEntrypoints.checkJNICountDownToGC();
    RVMField field = MemberReference.getFieldRef(fieldID).resolve();
    return env.pushJNIRef(java.lang.reflect.JikesRVMSupport.createField(field));
}
Also used : RVMField(org.jikesrvm.classloader.RVMField)

Example 7 with RVMField

use of org.jikesrvm.classloader.RVMField in project JikesRVM by JikesRVM.

the class JNIFunctions method SetCharField.

/**
 * SetCharField: set an instance field of type char
 * @param env A JREF index for the JNI environment object
 * @param objJREF a JREF index for the target object
 * @param fieldID the id for the RVMField that describes this field
 * @param value   char value to assign
 */
private static void SetCharField(JNIEnvironment env, int objJREF, int fieldID, char value) {
    if (traceJNI)
        VM.sysWriteln("JNI called: SetCharField");
    RuntimeEntrypoints.checkJNICountDownToGC();
    try {
        Object obj = env.getJNIRef(objJREF);
        RVMField field = MemberReference.getFieldRef(fieldID).resolve();
        field.setCharValueUnchecked(obj, value);
    } catch (Throwable unexpected) {
        if (traceJNI)
            unexpected.printStackTrace(System.err);
        env.recordException(unexpected);
    }
}
Also used : RVMField(org.jikesrvm.classloader.RVMField)

Example 8 with RVMField

use of org.jikesrvm.classloader.RVMField in project JikesRVM by JikesRVM.

the class JNIFunctions method GetObjectField.

/**
 * GetObjectField: read a instance field of type Object
 * @param env A JREF index for the JNI environment object
 * @param objJREF a JREF index for the target object
 * @param fieldID the id for the RVMField that describes this field
 * @return the value of the Object field, converted to a JREF index
 *         or 0 if the fieldID is incorrect
 */
private static int GetObjectField(JNIEnvironment env, int objJREF, int fieldID) {
    if (traceJNI)
        VM.sysWriteln("JNI called: GetObjectField");
    RuntimeEntrypoints.checkJNICountDownToGC();
    try {
        Object obj = env.getJNIRef(objJREF);
        RVMField field = MemberReference.getFieldRef(fieldID).resolve();
        Object objVal = field.getObjectUnchecked(obj);
        return env.pushJNIRef(objVal);
    } catch (Throwable unexpected) {
        if (traceJNI)
            unexpected.printStackTrace(System.err);
        env.recordException(unexpected);
        return 0;
    }
}
Also used : RVMField(org.jikesrvm.classloader.RVMField)

Example 9 with RVMField

use of org.jikesrvm.classloader.RVMField in project JikesRVM by JikesRVM.

the class JNIFunctions method SetByteField.

/**
 * SetByteField: set an instance field of type byte
 * @param env A JREF index for the JNI environment object
 * @param objJREF a JREF index for the target object
 * @param fieldID the id for the RVMField that describes this field
 * @param value   byte value to assign
 */
private static void SetByteField(JNIEnvironment env, int objJREF, int fieldID, byte value) {
    if (traceJNI)
        VM.sysWriteln("JNI called: SetByteField");
    RuntimeEntrypoints.checkJNICountDownToGC();
    try {
        Object obj = env.getJNIRef(objJREF);
        RVMField field = MemberReference.getFieldRef(fieldID).resolve();
        field.setByteValueUnchecked(obj, value);
    } catch (Throwable unexpected) {
        if (traceJNI)
            unexpected.printStackTrace(System.err);
        env.recordException(unexpected);
    }
}
Also used : RVMField(org.jikesrvm.classloader.RVMField)

Example 10 with RVMField

use of org.jikesrvm.classloader.RVMField in project JikesRVM by JikesRVM.

the class JNIFunctions method SetShortField.

/**
 * SetShortField: set an instance field of type short
 * @param env A JREF index for the JNI environment object
 * @param objJREF a JREF index for the target object
 * @param fieldID the id for the RVMField that describes this field
 * @param value   short value to assign
 */
private static void SetShortField(JNIEnvironment env, int objJREF, int fieldID, short value) {
    if (traceJNI)
        VM.sysWriteln("JNI called: SetShortField");
    RuntimeEntrypoints.checkJNICountDownToGC();
    try {
        Object obj = env.getJNIRef(objJREF);
        RVMField field = MemberReference.getFieldRef(fieldID).resolve();
        field.setShortValueUnchecked(obj, value);
    } catch (Throwable unexpected) {
        if (traceJNI)
            unexpected.printStackTrace(System.err);
        env.recordException(unexpected);
    }
}
Also used : RVMField(org.jikesrvm.classloader.RVMField)

Aggregations

RVMField (org.jikesrvm.classloader.RVMField)80 TypeReference (org.jikesrvm.classloader.TypeReference)21 Offset (org.vmmagic.unboxed.Offset)14 RVMClass (org.jikesrvm.classloader.RVMClass)12 Operand (org.jikesrvm.compilers.opt.ir.operand.Operand)9 Field (java.lang.reflect.Field)8 Instruction (org.jikesrvm.compilers.opt.ir.Instruction)8 RegisterOperand (org.jikesrvm.compilers.opt.ir.operand.RegisterOperand)8 Atom (org.jikesrvm.classloader.Atom)7 IntConstantOperand (org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand)6 LocationOperand (org.jikesrvm.compilers.opt.ir.operand.LocationOperand)6 RVMType (org.jikesrvm.classloader.RVMType)5 AddressConstantOperand (org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand)5 MethodOperand (org.jikesrvm.compilers.opt.ir.operand.MethodOperand)5 Address (org.vmmagic.unboxed.Address)5 FieldReference (org.jikesrvm.classloader.FieldReference)4 RVMMethod (org.jikesrvm.classloader.RVMMethod)4 BranchProfileOperand (org.jikesrvm.compilers.opt.ir.operand.BranchProfileOperand)4 ConditionOperand (org.jikesrvm.compilers.opt.ir.operand.ConditionOperand)4 TIBConstantOperand (org.jikesrvm.compilers.opt.ir.operand.TIBConstantOperand)4