From 6be70973a704548a42e396e996c9d49915b92a64 Mon Sep 17 00:00:00 2001 From: mwebster Date: Fri, 25 Aug 2006 14:37:34 +0000 Subject: Bug 155148 "jdk14 trace deadlock in oc4j" (use formatObj for _all_ arguments) --- .../org/aspectj/weaver/tools/AbstractTrace.java | 12 +++++-- .../org/aspectj/weaver/AbstractTraceTest.java | 41 +++++++++++++++++++--- 2 files changed, 47 insertions(+), 6 deletions(-) (limited to 'weaver') diff --git a/weaver/src/org/aspectj/weaver/tools/AbstractTrace.java b/weaver/src/org/aspectj/weaver/tools/AbstractTrace.java index 23d2aba39..28755dfd2 100644 --- a/weaver/src/org/aspectj/weaver/tools/AbstractTrace.java +++ b/weaver/src/org/aspectj/weaver/tools/AbstractTrace.java @@ -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 diff --git a/weaver/testsrc/org/aspectj/weaver/AbstractTraceTest.java b/weaver/testsrc/org/aspectj/weaver/AbstractTraceTest.java index 8f895a81b..334690b62 100644 --- a/weaver/testsrc/org/aspectj/weaver/AbstractTraceTest.java +++ b/weaver/testsrc/org/aspectj/weaver/AbstractTraceTest.java @@ -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() { -- cgit v1.2.3