1 package gov.nasa.jpf.jvm; 20 21 import org.apache.bcel.classfile.JavaClass; 22 import org.apache.bcel.classfile.Method; 23 import org.apache.bcel.classfile.Field; 24 25 30 public class DefaultAttributor implements Attributor { 31 32 35 public boolean isMethodAtomic (JavaClass jc, Method mth, String uniqueName) { 36 37 if (jc.getPackageName().startsWith( "java.")) { 40 String clsName = jc.getClassName(); 41 42 if (clsName.equals("java.lang.Object")) { 44 if (uniqueName.startsWith("wait(") || 45 uniqueName.equals("notify()")) { 46 return false; 47 } 48 } else if (clsName.equals("java.lang.Thread")) { 49 if (uniqueName.equals("join()")) { 50 return false; 51 } 52 } 53 54 return true; 55 } 56 57 return false; 58 } 59 60 64 public int getSchedulingRelevance (JavaClass jc, Method mth, String uniqueName) { 65 String cls = jc.getClassName(); 66 67 if (cls.equals("java.lang.Thread")) { 68 if (uniqueName.equals("start()")) { 69 75 } else if (uniqueName.equals("yield()") || 77 uniqueName.equals("sleep(J)") || 78 uniqueName.equals("join()")) { 79 return MethodInfo.SR_RUNNABLES; 80 } 81 } else if (cls.equals("java.lang.Object")) { 82 if ( 83 uniqueName.equals("wait(J)") || 84 uniqueName.equals("notify()")) { 85 return MethodInfo.SR_RUNNABLES; 86 } 87 } else if (cls.equals("gov.nasa.jpf.jvm.Verify")) { 88 if (uniqueName.equals("beginAtomic()") || 91 uniqueName.equals("endAtomic()")) { 92 } 94 } 95 96 if (mth.isSynchronized()) { 97 return MethodInfo.SR_SYNC; 98 } 99 100 return MethodInfo.SR_NEVER; 101 } 102 103 107 public int getObjectAttributes (JavaClass jc) { 108 String clsName = jc.getClassName(); 109 110 if (clsName.equals("java.lang.String") || 112 clsName.equals("java.lang.Integer") || 113 clsName.equals("java.lang.Long") || 114 clsName.equals("java.lang.Class") 115 116 ) { 117 return ElementInfo.ATTR_IMMUTABLE; 118 } else { 119 return 0; 120 } 121 } 122 123 public int getFieldAttributes (JavaClass jc, Field f) { 124 String clsName = jc.getClassName(); 125 String fName = f.getName(); 126 127 if (clsName.equals("java.lang.ThreadGroup")) { 128 if (fName.equals("threads")) { 129 return ElementInfo.ATTR_PROP_MASK & ~ElementInfo.ATTR_TSHARED; 130 } 131 } 132 133 return ElementInfo.ATTR_PROP_MASK; 134 } 135 } 136 137 | Popular Tags |