}
public void setShortField (int objref, String fname, short val) {
- setIntField(objref, fname, /*(int)*/ val);
+ ElementInfo ei = heap.getModifiable(objref);
+ ei.setShortField(fname, val);
}
public short getShortField (int objref, String fname) {
- return (short) getIntField(objref, fname);
+ ElementInfo ei = heap.get(objref);
+ return ei.getShortField(fname);
}
/**
@MJI
public int get__Ljava_lang_Object_2I__Ljava_lang_Object_2 (MJIEnv env, int clsRef,
int aref, int index){
- String at = env.getArrayType(aref);
+ String at = Types.getTypeName(env.getArrayType(aref));
if (at.equals("int")){
int vref = env.newObject("java.lang.Integer");
env.setIntField(vref, "value", env.getIntArrayElement(aref,index));
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import java.lang.reflect.Array;
import java.lang.reflect.Field;
import org.junit.Test;
public class Sub {
public int f;
}
+
+ public static class ShortField {
+ short f;
+ }
@Test
public void getDeclaredAnnotationsTest () throws SecurityException, NoSuchFieldException{
assertEquals(f2.getDeclaredAnnotations().length, 1);
}
}
+
+ @Test
+ public void getSetShortFieldTest() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
+ if(verifyNoPropertyViolation()) {
+ ShortField sf = new ShortField();
+ Field f = sf.getClass().getField("f");
+ f.set(sf, (short)3);
+ assertEquals((short)f.get(sf), (short)3);
+
+ short[] x = new short[] {1,2,3};
+ Array.setShort(x, 0, (short) 3);
+ assertEquals(Array.getShort(x, 0), (short)3);
+ }
+ }
}