diff options
author | acolyer <acolyer> | 2005-09-26 19:11:55 +0000 |
---|---|---|
committer | acolyer <acolyer> | 2005-09-26 19:11:55 +0000 |
commit | 20cafd486b5f5181153fadc4179c2cf313c931a5 (patch) | |
tree | d39d479a80e60ce4ddffcede0ceeb8fa3707a0ee | |
parent | cf077b3b71ae47a556e230eb40dfa158abd4d037 (diff) | |
download | aspectj-20cafd486b5f5181153fadc4179c2cf313c931a5.tar.gz aspectj-20cafd486b5f5181153fadc4179c2cf313c931a5.zip |
a few more tweaks to fix for pr108123 and pr106500 - better diagnostics and exceptions, plus support for -Xdev:Pinpoint
6 files changed, 34 insertions, 16 deletions
diff --git a/bridge/src/org/aspectj/bridge/context/CompilationAndWeavingContext.java b/bridge/src/org/aspectj/bridge/context/CompilationAndWeavingContext.java index 208bc696b..f99146864 100644 --- a/bridge/src/org/aspectj/bridge/context/CompilationAndWeavingContext.java +++ b/bridge/src/org/aspectj/bridge/context/CompilationAndWeavingContext.java @@ -150,11 +150,11 @@ public class CompilationAndWeavingContext { explanationStack.push(getFormatter(entry).formatEntry(entry.phaseId,entry.data)); } StringBuffer sb = new StringBuffer(); - for (Iterator iter = explanationStack.iterator(); iter.hasNext();) { + while (!explanationStack.isEmpty()) { sb.append("when "); - sb.append(iter.next().toString()); + sb.append(explanationStack.pop().toString()); sb.append("\n"); - } + } return sb.toString(); } @@ -215,6 +215,10 @@ public class CompilationAndWeavingContext { this.phaseId = phase; this.data = data; } + + public String toString() { + return CompilationAndWeavingContext.getFormatter(this).formatEntry(phaseId, data); + } } private static class DefaultFormatter implements ContextFormatter { diff --git a/bridge/testsrc/org/aspectj/bridge/context/CompilationAndWeavingContextTest.java b/bridge/testsrc/org/aspectj/bridge/context/CompilationAndWeavingContextTest.java index 6e8c73e22..825a52b61 100644 --- a/bridge/testsrc/org/aspectj/bridge/context/CompilationAndWeavingContextTest.java +++ b/bridge/testsrc/org/aspectj/bridge/context/CompilationAndWeavingContextTest.java @@ -27,7 +27,7 @@ public class CompilationAndWeavingContextTest extends TestCase { public void testDoubleEntry() { CompilationAndWeavingContext.enteringPhase(1,"XYZ"); CompilationAndWeavingContext.enteringPhase(2, "ABC"); - assertEquals("when fiddling XYZ\nwhen mucking about with ABC\n",CompilationAndWeavingContext.getCurrentContext()); + assertEquals("when mucking about with ABC\nwhen fiddling XYZ\n",CompilationAndWeavingContext.getCurrentContext()); } public void testEntryEntryExit() { diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java index 5b64bd471..71c5d6085 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java @@ -568,7 +568,10 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC // future generations to enjoy. Method source is commented out at the end of this module // doDeclareAnnotationOnFields(); - if (skipInners) return; + if (skipInners) { + CompilationAndWeavingContext.leavingPhase(tok); + return; + } ReferenceBinding[] memberTypes = sourceType.memberTypes; for (int i = 0, length = memberTypes.length; i < length; i++) { diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java index 55ddf133a..2373f0456 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java @@ -176,7 +176,8 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc boolean canIncremental = state.prepareForNextBuild(buildConfig); if (!canIncremental && !batch) { // retry as batch? - return doBuild(buildConfig, baseHandler, true); + CompilationAndWeavingContext.leavingPhase(ct); + return doBuild(buildConfig, baseHandler, true); } this.handler = CountingMessageHandler.makeCountingMessageHandler(baseHandler); @@ -185,6 +186,7 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc if (check != null) { if (FAIL_IF_RUNTIME_NOT_FOUND) { MessageUtil.error(handler, check); + CompilationAndWeavingContext.leavingPhase(ct); return false; } else { MessageUtil.warn(handler, check); @@ -202,11 +204,15 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc initBcelWorld(handler); } if (handler.hasErrors()) { + CompilationAndWeavingContext.leavingPhase(ct); return false; } if (buildConfig.getOutputJar() != null) { - if (!openOutputStream(buildConfig.getOutputJar())) return false; + if (!openOutputStream(buildConfig.getOutputJar())) { + CompilationAndWeavingContext.leavingPhase(ct); + return false; + } } if (batch) { @@ -218,6 +224,7 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc binarySourcesForTheNextCompile = state.getBinaryFilesToCompile(true); performCompilation(buildConfig.getFiles()); if (handler.hasErrors()) { + CompilationAndWeavingContext.leavingPhase(ct); return false; } @@ -241,6 +248,7 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc performCompilation(files); if (handler.hasErrors() || (progressListener!=null && progressListener.isCancelledRequested())) { + CompilationAndWeavingContext.leavingPhase(ct); return false; } binarySourcesForTheNextCompile = state.getBinaryFilesToCompile(false); @@ -257,6 +265,7 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc AsmManager.getDefault().processDelta(files,state.addedFiles,state.deletedFiles); } if (!files.isEmpty()) { + CompilationAndWeavingContext.leavingPhase(ct); return batchBuild(buildConfig, baseHandler); } else { if (AsmManager.isReporting()) @@ -279,8 +288,9 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc if (buildConfig.isGenerateModelMode()) { AsmManager.getDefault().fireModelUpdated(); } + CompilationAndWeavingContext.leavingPhase(ct); + } finally { - CompilationAndWeavingContext.leavingPhase(ct); if (zos != null) { closeOutputStream(buildConfig.getOutputJar()); } diff --git a/org.aspectj.ajdt.core/src/org/aspectj/tools/ajc/Main.java b/org.aspectj.ajdt.core/src/org/aspectj/tools/ajc/Main.java index e250c6b29..e34ec6ce1 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/tools/ajc/Main.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/tools/ajc/Main.java @@ -144,7 +144,7 @@ public class Main { String m = thrown.getMessage(); return THROWN_PREFIX + (null != m ? m + "\n": "") - + CompilationAndWeavingContext.getCurrentContext() + + "\n" + CompilationAndWeavingContext.getCurrentContext() + LangUtil.renderException(thrown, true); } diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java b/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java index 1aefee5b9..275094c88 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java @@ -1455,14 +1455,15 @@ public class BcelWeaver implements IWeaver { return clazz; } } catch (RuntimeException re) { - System.err.println("trouble in: "); - clazz.print(System.err); - re.printStackTrace(); - throw re; + String messageText = "trouble in: \n" + clazz.toLongString(); + getWorld().getMessageHandler().handleMessage( + new Message(messageText,IMessage.ABORT,re,null) + ); } catch (Error re) { - System.err.println("trouble in: "); - clazz.print(System.err); - throw re; + String messageText = "trouble in: \n" + clazz.toLongString(); + getWorld().getMessageHandler().handleMessage( + new Message(messageText,IMessage.ABORT,re,null) + ); } } |