1 20 package gov.nasa.jpf.jvm; 21 22 25 public class JPF_gov_nasa_jpf_jvm_TestNativePeer { 26 public static void $clinit (MJIEnv env, int rcls) { 27 env.setStaticIntField(rcls, "sdata", 42); 28 } 29 30 public static void $init__I (MJIEnv env, int robj, int i) { 31 env.setIntField(robj, "idata", i); 32 } 33 34 public static int nativeCreate2DimIntArray (MJIEnv env, int robj, int size1, 35 int size2) { 36 int ar = env.newObjectArray("[I", size1); 37 38 for (int i = 0; i < size1; i++) { 39 int ea = env.newIntArray(size2); 40 41 if (i == 1) { 42 env.setIntArrayElement(ea, 1, 42); 43 } 44 45 env.setReferenceArrayElement(ar, i, ea); 46 } 47 48 return ar; 49 } 50 51 public static int nativeCreateIntArray (MJIEnv env, int robj, int size) { 52 int ar = env.newIntArray(size); 53 54 env.setIntArrayElement(ar, 1, 1); 55 56 return ar; 57 } 58 59 public static int nativeCreateStringArray (MJIEnv env, int robj, int size) { 60 int ar = env.newObjectArray("Ljava/lang/String;", size); 61 62 env.setReferenceArrayElement(ar, 1, env.newString("one")); 63 64 return ar; 65 } 66 67 public static void nativeException (MJIEnv env, int robj) { 68 env.throwException("java.lang.UnsupportedOperationException", "caught me"); 69 } 70 71 public static int nativeCrash (MJIEnv env, int robj) { 72 String s = null; 73 return s.length(); 74 } 75 76 public static int nativeInstanceMethod (MJIEnv env, int robj, double d, 77 char c, boolean b, int i) { 78 if ((d == 2.0) && (c == '?') && b) { 79 return i + 2; 80 } 81 82 return 0; 83 } 84 85 public static long nativeStaticMethod (MJIEnv env, int rcls, long l, 86 int stringRef) { 87 String s = env.getStringObject(stringRef); 88 89 if ("Blah".equals(s)) { 90 return l + 2; 91 } 92 93 return 0; 94 } 95 } 96 | Popular Tags |