1 4 package com.tc.object.config; 5 6 import com.tc.object.bytecode.ByteCodeUtil; 7 8 import java.util.HashSet ; 9 import java.util.Hashtable ; 10 import java.util.Set ; 11 12 public class TransparencyCodeSpec { 13 private final static Set MONITOR_INSTRUMENTATION_REQ_LOGICAL_CLASS = new HashSet (); 14 15 private boolean arrayOperatorInstrumentationReq; 16 private boolean arraycopyInstrumentationReq; 17 private boolean fieldInstrumentationReq; 18 private boolean waitNotifyInstrumentationReq; 19 private boolean monitorInstrumentationReq; 20 21 static { 22 MONITOR_INSTRUMENTATION_REQ_LOGICAL_CLASS.add(Hashtable .class.getName()); 23 } 24 25 public static TransparencyCodeSpec getDefaultPhysicalCodeSpec() { 26 TransparencyCodeSpec defaultPhysicalCodeSpec = new TransparencyCodeSpec(); 27 defaultPhysicalCodeSpec.setArrayOperatorInstrumentationReq(true); 28 defaultPhysicalCodeSpec.setArraycopyInstrumentationReq(true); 29 defaultPhysicalCodeSpec.setFieldInstrumentationReq(true); 30 defaultPhysicalCodeSpec.setWaitNotifyInstrumentationReq(true); 31 defaultPhysicalCodeSpec.setMonitorInstrumentationReq(true); 32 return defaultPhysicalCodeSpec; 33 } 34 35 public static TransparencyCodeSpec getDefaultLogicalCodeSpec() { 36 TransparencyCodeSpec defaultSpec = new TransparencyCodeSpec(); 37 return defaultSpec; 38 } 39 40 public static TransparencyCodeSpec getDefaultCodeSpec(String className, boolean isLogical, boolean isAutolock) { 41 if (isLogical) { 42 TransparencyCodeSpec codeSpec = getDefaultLogicalCodeSpec(); 43 if (MONITOR_INSTRUMENTATION_REQ_LOGICAL_CLASS.contains(className)) { 44 codeSpec.setMonitorInstrumentationReq(isAutolock); 45 } 46 return codeSpec; 47 } 48 return getDefaultPhysicalCodeSpec(); 49 } 50 51 public TransparencyCodeSpec() { 52 super(); 53 } 54 55 public boolean isArraycopyInstrumentationReq(String className, String methodName) { 56 return arraycopyInstrumentationReq && "java/lang/System".equals(className) && "arraycopy".equals(methodName); 57 } 58 59 public void setArraycopyInstrumentationReq(boolean arraycopyInstrumentationReq) { 60 this.arraycopyInstrumentationReq = arraycopyInstrumentationReq; 61 } 62 63 public boolean isArrayOperatorInstrumentationReq() { 64 return arrayOperatorInstrumentationReq; 65 } 66 67 public void setArrayOperatorInstrumentationReq(boolean arrayOperatorInstrumentationReq) { 68 this.arrayOperatorInstrumentationReq = arrayOperatorInstrumentationReq; 69 } 70 71 public boolean isFieldInstrumentationReq(String fieldName) { 72 return fieldInstrumentationReq && !ByteCodeUtil.isTCSynthetic(fieldName); 78 } 79 80 public void setFieldInstrumentationReq(boolean fieldInstrumentationReq) { 81 this.fieldInstrumentationReq = fieldInstrumentationReq; 82 } 83 84 public boolean isWaitNotifyInstrumentationReq() { 85 return waitNotifyInstrumentationReq; 86 } 87 88 public void setWaitNotifyInstrumentationReq(boolean waitNotifyInstrumentationReq) { 89 this.waitNotifyInstrumentationReq = waitNotifyInstrumentationReq; 90 } 91 92 public boolean isMonitorInstrumentationReq() { 93 return monitorInstrumentationReq; 94 } 95 96 public void setMonitorInstrumentationReq(boolean monitorInstrumentationReq) { 97 this.monitorInstrumentationReq = monitorInstrumentationReq; 98 } 99 100 } 101 | Popular Tags |