1 package gov.nasa.jpf.jvm; 20 21 import gov.nasa.jpf.JPFException; 22 23 24 27 public class JPF_java_lang_Object { 28 public static int getClass (MJIEnv env, int objref) { 29 ClassInfo oci = env.getClassInfo(objref); 30 31 return oci.getClassObjectRef(); 32 } 33 34 public static boolean $isDeterministic_wait__J (MJIEnv env, int objref, 35 long length) { 36 return (length == 0); 37 } 38 39 public static boolean $isExecutable_wait__J (MJIEnv env, int objref, 40 long length) { 41 ThreadInfo ti = env.getThreadInfo(); 42 43 if (length != 0) { 44 if (env.getSystemState().random(2) == 0) { 45 return true; 46 } 47 } 48 49 switch (ti.getStatus()) { 50 case ThreadInfo.RUNNING: 51 case ThreadInfo.SYNC_RUNNING: 52 return true; 53 54 case ThreadInfo.NOTIFIED: 55 return env.canLock(objref); 56 57 case ThreadInfo.INTERRUPTED: 58 return env.canLock(objref); 59 60 default: 61 62 return false; 63 } 64 } 65 66 public static int clone (MJIEnv env, int objref) { 67 return -1; 69 } 70 71 public static int hashCode (MJIEnv env, int objref) { 72 return (objref ^ 0xABCD); 73 } 74 75 public static void notifyAll (MJIEnv env, int objref) { 76 env.notifyAll(objref); 77 } 78 79 public static void registerNatives (MJIEnv env, int clsObjRef) { 80 } 82 83 public static void wait__J (MJIEnv env, int objref, long length) { 84 ThreadInfo ti = env.getThreadInfo(); 85 86 if (length != 0) { 87 if (env.getSystemState().random(2) == 0) { 88 return; 89 } 90 } 91 92 switch (ti.getStatus()) { 93 case ThreadInfo.RUNNING: 94 case ThreadInfo.SYNC_RUNNING: 95 96 env.wait(objref); 97 env.repeatInvocation(); 98 99 break; 100 101 case ThreadInfo.NOTIFIED: 102 env.lockNotified(objref); 103 104 break; 105 106 case ThreadInfo.INTERRUPTED: 107 env.lockNotified(objref); 108 env.throwException("java.lang.InterruptedException"); 109 110 break; 111 112 default: 113 114 throw new JPFException("invalid thread state"); 116 } 117 } 118 119 public static final void notify (MJIEnv env, int objref) { 120 env.notify(objref); 121 } 122 } 123 | Popular Tags |