@@ -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 { |
@@ -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() { |
@@ -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++) { |
@@ -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()); | |||
} |
@@ -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); | |||
} | |||
@@ -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) | |||
); | |||
} | |||
} | |||