1 4 package com.tc.object.bytecode; 5 6 import org.apache.commons.lang.ArrayUtils; 7 8 import com.tc.asm.MethodVisitor; 9 import com.tc.logging.TCLogger; 10 import com.tc.object.config.LockDefinition; 11 12 15 public class PhysicalClassAdapterLogger { 16 private final TCLogger logger; 17 18 PhysicalClassAdapterLogger(TCLogger l) { 19 this.logger = l; 20 } 21 22 void logVisitMethodCreateLockMethod(String name) { 23 if (logger.isDebugEnabled()) logger.debug("Creating lock:" + name); 24 } 25 26 void logVisitMethodNotALockMethod(final int access, final String ownerClass, String name, final String desc, 27 final String [] exceptions) { 28 if (logger.isDebugEnabled()) logger.debug("visitMethod(): Not a lock method: " + access + " " + ownerClass + "." 29 + name + desc + " " + arrayToString(exceptions)); 30 } 31 32 void logVisitMethodBegin(final int access, String name, String signature, final String desc, final String [] exceptions) { 33 if (logger.isDebugEnabled()) logger.debug("visitMethod(" + access + ", " + name + ", " + desc + ", " 34 + arrayToString(exceptions) + ", " + signature + ")"); 35 } 36 37 void logVisitMethodIgnoring(String name, final String desc) { 38 if (logger.isDebugEnabled()) logger.debug("Ignoring:" + name + " desc:" + desc); 39 } 40 41 void logVisitMethodCheckIsLockMethod() { 42 if (logger.isDebugEnabled()) logger.debug("Checking isLockMethod()"); 43 } 44 45 void logCallTCBeginWithLocksStart(int access, String name, String desc, LockDefinition[] locks, MethodVisitor c) { 46 if (logger.isDebugEnabled()) { 47 logger.debug("callTCBeginWithLocks(access=" + access + ", name=" + name + ", desc=" + desc + ", locks=" 48 + arrayToString(locks) + ", c= " + c + ")"); 49 } 50 } 51 52 void logCallTCBeginWithLocksAutolock() { 53 if (logger.isDebugEnabled()) logger.debug("callTCBeginWithLocks(): lock is autolock."); 54 } 55 56 void logCallTCBeginWithLocksAutolockSynchronized(String name, String desc) { 57 if (logger.isDebugEnabled()) { 58 logger.debug("callTCBeginWithLocks(): method is synchronized, calling __tcmonitorenter() for method " + name 59 + "." + desc); 60 } 61 } 62 63 void logCallTCBeginWithLocksAutolockNotSynchronized(String name, String desc) { 64 if (logger.isDebugEnabled()) { 65 logger.debug("callTCBeginWithLocks(): method is not synchronized, ignoring autolock for method " + name + "." 66 + desc); 67 } 68 } 69 70 void logCallTCBeginWithLocksNoAutolock(LockDefinition lock) { 71 if (logger.isDebugEnabled()) logger.debug("calling callTCBeginWithLock() for lock " + lock); 72 } 73 74 void logCreateLockMethodBegin(int access, String name, String signature, String desc, final String [] exceptions, 75 LockDefinition[] locks) { 76 if (logger.isDebugEnabled()) logger.debug("createLockMethod(access=" + access + ", name=" + name + ", desc=" + desc 77 + ", exceptions=" + arrayToString(exceptions) + ", " + signature + ", " 78 + arrayToString(locks) + ")"); 79 } 80 81 void logCreateLockMethodVoidBegin(int access, String name, String signature, String desc, final String [] exceptions, 82 LockDefinition[] locks) { 83 if (logger.isDebugEnabled()) { 84 logger.debug("createLockMethodVoid(access=" + access + ", name=" + name + ", desc=" + desc + ", exceptions=" 85 + arrayToString(exceptions) + ", sig=" + signature + ", locks=" + arrayToString(locks)); 86 } 87 } 88 89 void logCallTCCommitBegin(int access, String name, String desc, LockDefinition[] locks, MethodVisitor c) { 90 if (logger.isDebugEnabled()) logger.debug("callTCCommit(access=" + access + ", name=" + name + ", desc=" + desc 91 + ", locks=" + arrayToString(locks) + ", c=" + c + ")"); 92 } 93 94 void logCreateLockMethodReturnBegin(int access, String name, String signature, String desc, 95 final String [] exceptions, LockDefinition[] locks) { 96 if (logger.isDebugEnabled()) logger.debug("createLockMethodReturn(access=" + access + ", name=" + name + ", desc=" 97 + desc + ", exceptions=" + arrayToString(exceptions) + ", signature=" 98 + signature + ", locks=" + arrayToString(locks) + ")"); 99 } 100 101 private String arrayToString(Object obj) { 102 return obj == null ? "null" : ArrayUtils.toString(obj); 103 } 104 } | Popular Tags |