]> source.dussan.org Git - aspectj.git/commitdiff
Bug 155148 "jdk14 trace deadlock in oc4j" (use formatObj for _all_ arguments)
authormwebster <mwebster>
Fri, 25 Aug 2006 14:37:34 +0000 (14:37 +0000)
committermwebster <mwebster>
Fri, 25 Aug 2006 14:37:34 +0000 (14:37 +0000)
loadtime/src/org/aspectj/weaver/loadtime/DefaultWeavingContext.java
weaver/src/org/aspectj/weaver/tools/AbstractTrace.java
weaver/testsrc/org/aspectj/weaver/AbstractTraceTest.java
weaver5/java5-src/org/aspectj/weaver/tools/Jdk14Trace.java

index bd4c3280f626634fd00cfd0428c3f8cb1a8b4b49..403a3576fb0843b8c21fc5af3651b53060c0a4c0 100644 (file)
@@ -53,7 +53,7 @@ public class DefaultWeavingContext implements IWeavingContext {
         * @return classname@hashcode
         */
        public String getClassLoaderName() {
-       return ((loader!=null)?loader.getClass().getName()+"@"+loader.hashCode():"null");
+       return ((loader!=null)?loader.getClass().getName()+"@"+Integer.toHexString(loader.hashCode()):"null");
        }
 
        /**
index 23d2aba39ddce121a3dcd6ae959f1196f93306c3..28755dfd2b17b1140b0813a42c81f0d77bcdbfac 100644 (file)
@@ -139,11 +139,11 @@ public abstract class AbstractTrace implements Trace {
                        }
                        
                        /* Use classname@hashcode */
-                       else return obj.getClass().getName() + "@" + Integer.toString(obj.hashCode(),16);
+                       else return obj.getClass().getName() + "@" + Integer.toHexString(obj.hashCode());
                
                /* Object.hashCode() can be override and may thow an exception */       
                } catch (Exception ex) {
-                       return obj.getClass().getName();
+                       return obj.getClass().getName() + "@FFFFFFFF";
                }
        }
        
@@ -172,4 +172,12 @@ public abstract class AbstractTrace implements Trace {
                
                return sb.toString();
        }
+       
+       protected Object[] formatObjects(Object[] args) {
+               for (int i = 0; i < args.length; i++) {
+                       args[i] = formatObj(args[i]);
+               }
+               
+               return args;
+       }
 }
\ No newline at end of file
index 8f895a81b41d13a1ad7f1d03ff4b902a45cf67ff..334690b6291f8b080bf43133af07914a800bf4f4 100644 (file)
@@ -34,23 +34,56 @@ public abstract class AbstractTraceTest extends TestCase {
        public void testEnterWithThisAndArray() {
                Object arg1 = new String[] { "s1", "s2" };
                Object arg2 = new char[] { 'a', 'b', 'c' };
-               trace.enter("testEnterWithThisAndArgs",this,new Object[] { arg1, arg2 });
+               trace.enter(getName(),this,new Object[] { arg1, arg2 });
        }
 
        public void testEnterWithThisAndCollection() {
                Object arg1 = new ArrayList();
-               trace.enter("testEnterWithThisAndArgs",this,new Object[] { arg1 });
+               trace.enter(getName(),this,new Object[] { arg1 });
        }
 
        public void testEnterWithThisAndTraceable () {
                Object arg1 = new Traceable() {
 
                        public String toTraceString() {
-                               return "Traceable";
+                               return getClass().getName() + "[Traceable]";
                        }
                        
                };
-               trace.enter("testEnterWithThisAndArgs",this,new Object[] { arg1 });
+               trace.enter(getName(),this,new Object[] { arg1 });
+       }
+
+       public void testEnterWithThisAndToStringException () {
+               Object arg1 = new Object() {
+
+                       public String toString() {
+                               throw new RuntimeException("toString() can throw an Exception");
+                       }
+                       
+               };
+               trace.enter(getName(),this,new Object[] { arg1 });
+       }
+
+       public void testEnterWithThisAndHashCodeException () {
+               Object arg1 = new Object() {
+
+                       public int hashCode() {
+                               throw new RuntimeException("hashCode can throw an Exception");
+                       }
+                       
+               };
+               trace.enter(getName(),this,new Object[] { arg1 });
+       }
+
+       public void testEnterWithThisAndClassLoader () {
+               Object arg1 = new ClassLoader() {
+
+                       public String toString() {
+                               throw new Error("Don't call ClassLoader.toString()");
+                       }
+                       
+               };
+               trace.enter(getName(),this,new Object[] { arg1 });
        }
 
        public void testEnterWithThis() {
index 28c46d4eadf4b9a722de144c0fbb7e15105707b5..7072ffcb6f479ac197172e6b0d9aad05e5537dfc 100644 (file)
@@ -29,7 +29,7 @@ public class Jdk14Trace extends AbstractTrace {
                if (logger.isLoggable(Level.FINE)) {
                        logger.entering(name,methodName,formatObj(thiz));
                        if (args != null && logger.isLoggable(Level.FINER)) {
-                               logger.entering(name,methodName,args);
+                               logger.entering(name,methodName,formatObjects(args));
                        }                       
                }
        }
@@ -40,7 +40,7 @@ public class Jdk14Trace extends AbstractTrace {
 
        public void exit(String methodName, Object ret) {
                if (logger.isLoggable(Level.FINE)) {
-                       logger.exiting(name,methodName,ret);
+                       logger.exiting(name,methodName,formatObj(ret));
                }
        }
 
@@ -60,7 +60,7 @@ public class Jdk14Trace extends AbstractTrace {
                if (logger.isLoggable(Level.FINE)) {
                        logger.logp(Level.FINER,name,methodName,"EVENT",formatObj(thiz));
                        if (args != null && logger.isLoggable(Level.FINER)) {
-                               logger.logp(Level.FINER,name,methodName,"EVENT",args);
+                               logger.logp(Level.FINER,name,methodName,"EVENT",formatObjects(args));
                        }                       
                }
        }