Search in sources :

Example 66 with RVMField

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

the class JNIFunctions method SetStaticLongField.

/**
 * SetStaticLongField:  set a static field of type long
 * @param env A JREF index for the JNI environment object
 * @param classJREF a JREF index for the RVMClass object
 * @param fieldID the id for the RVMField that describes this field
 * @param fieldValue  The value to assign
 */
private static void SetStaticLongField(JNIEnvironment env, int classJREF, int fieldID, long fieldValue) {
    if (traceJNI)
        VM.sysWriteln("JNI called: SetStaticLongField");
    RuntimeEntrypoints.checkJNICountDownToGC();
    try {
        RVMField field = MemberReference.getFieldRef(fieldID).resolve();
        field.setLongValueUnchecked(null, fieldValue);
    } catch (Throwable unexpected) {
        if (traceJNI)
            unexpected.printStackTrace(System.err);
        env.recordException(unexpected);
    }
}
Also used : RVMField(org.jikesrvm.classloader.RVMField)

Example 67 with RVMField

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

the class JNIFunctions method GetCharField.

/**
 * GetCharField:  read an instance field of type character
 * @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 character field, or 0 if the fieldID is incorrect
 */
private static int GetCharField(JNIEnvironment env, int objJREF, int fieldID) {
    if (traceJNI)
        VM.sysWriteln("JNI called: GetCharField");
    RuntimeEntrypoints.checkJNICountDownToGC();
    try {
        Object obj = env.getJNIRef(objJREF);
        RVMField field = MemberReference.getFieldRef(fieldID).resolve();
        return field.getCharValueUnchecked(obj);
    } catch (Throwable unexpected) {
        if (traceJNI)
            unexpected.printStackTrace(System.err);
        env.recordException(unexpected);
        return 0;
    }
}
Also used : RVMField(org.jikesrvm.classloader.RVMField)

Example 68 with RVMField

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

the class JNIFunctions method GetByteField.

/**
 * GetByteField:  read 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
 * @return the value of the byte field, or 0 if the fieldID is incorrect
 */
private static int GetByteField(JNIEnvironment env, int objJREF, int fieldID) {
    if (traceJNI)
        VM.sysWriteln("JNI called: GetByteField");
    RuntimeEntrypoints.checkJNICountDownToGC();
    try {
        Object obj = env.getJNIRef(objJREF);
        RVMField field = MemberReference.getFieldRef(fieldID).resolve();
        return field.getByteValueUnchecked(obj);
    } catch (Throwable unexpected) {
        if (traceJNI)
            unexpected.printStackTrace(System.err);
        env.recordException(unexpected);
        return 0;
    }
}
Also used : RVMField(org.jikesrvm.classloader.RVMField)

Example 69 with RVMField

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

the class JNIFunctions method FromReflectedField.

/**
 * FromReflectedField
 * @param env A JREF index for the JNI environment object
 * @param fieldJREF a JREF index for a java.lang.reflect.Field methodID
 * @return the jfieldID corresponding to fieldJREF
 */
private static int FromReflectedField(JNIEnvironment env, int fieldJREF) {
    if (traceJNI)
        VM.sysWriteln("JNI called: FromReflectedField");
    RuntimeEntrypoints.checkJNICountDownToGC();
    Field fieldObj = (Field) env.getJNIRef(fieldJREF);
    RVMField f = java.lang.reflect.JikesRVMSupport.getFieldOf(fieldObj);
    if (traceJNI)
        VM.sysWriteln("got field " + f);
    return f.getId();
}
Also used : RVMField(org.jikesrvm.classloader.RVMField) Field(java.lang.reflect.Field) RVMField(org.jikesrvm.classloader.RVMField)

Example 70 with RVMField

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

the class JNIFunctions method SetStaticObjectField.

/**
 * SetStaticObjectField:  set a static field of type Object
 * @param env         A JREF index for the JNI environment object
 * @param classJREF   A JREF index for the {@link RVMClass} object
 * @param fieldID     The id for the {@link RVMField} that describes this
 *                    field
 * @param objectJREF  A JREF index of the value to assign
 */
private static void SetStaticObjectField(JNIEnvironment env, int classJREF, int fieldID, int objectJREF) {
    if (traceJNI)
        VM.sysWriteln("JNI called: SetStaticObjectField");
    RuntimeEntrypoints.checkJNICountDownToGC();
    try {
        RVMField field = MemberReference.getFieldRef(fieldID).resolve();
        Object ref = env.getJNIRef(objectJREF);
        field.setObjectValueUnchecked(null, ref);
    } 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