Browse Source

a few more tweaks to fix for pr108123 and pr106500 - better diagnostics and exceptions, plus support for -Xdev:Pinpoint

tags/preDefaultReweavable
acolyer 19 years ago
parent
commit
20cafd486b

+ 7
- 3
bridge/src/org/aspectj/bridge/context/CompilationAndWeavingContext.java View File

explanationStack.push(getFormatter(entry).formatEntry(entry.phaseId,entry.data)); explanationStack.push(getFormatter(entry).formatEntry(entry.phaseId,entry.data));
} }
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
for (Iterator iter = explanationStack.iterator(); iter.hasNext();) {
while (!explanationStack.isEmpty()) {
sb.append("when "); sb.append("when ");
sb.append(iter.next().toString());
sb.append(explanationStack.pop().toString());
sb.append("\n"); sb.append("\n");
}
}
return sb.toString(); return sb.toString();
} }
this.phaseId = phase; this.phaseId = phase;
this.data = data; this.data = data;
} }
public String toString() {
return CompilationAndWeavingContext.getFormatter(this).formatEntry(phaseId, data);
}
} }
private static class DefaultFormatter implements ContextFormatter { private static class DefaultFormatter implements ContextFormatter {

+ 1
- 1
bridge/testsrc/org/aspectj/bridge/context/CompilationAndWeavingContextTest.java View File

public void testDoubleEntry() { public void testDoubleEntry() {
CompilationAndWeavingContext.enteringPhase(1,"XYZ"); CompilationAndWeavingContext.enteringPhase(1,"XYZ");
CompilationAndWeavingContext.enteringPhase(2, "ABC"); 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() { public void testEntryEntryExit() {

+ 4
- 1
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java View File

// future generations to enjoy. Method source is commented out at the end of this module // future generations to enjoy. Method source is commented out at the end of this module
// doDeclareAnnotationOnFields(); // doDeclareAnnotationOnFields();


if (skipInners) return;
if (skipInners) {
CompilationAndWeavingContext.leavingPhase(tok);
return;
}


ReferenceBinding[] memberTypes = sourceType.memberTypes; ReferenceBinding[] memberTypes = sourceType.memberTypes;
for (int i = 0, length = memberTypes.length; i < length; i++) { for (int i = 0, length = memberTypes.length; i < length; i++) {

+ 13
- 3
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java View File

boolean canIncremental = state.prepareForNextBuild(buildConfig); boolean canIncremental = state.prepareForNextBuild(buildConfig);
if (!canIncremental && !batch) { // retry as batch? if (!canIncremental && !batch) { // retry as batch?
return doBuild(buildConfig, baseHandler, true);
CompilationAndWeavingContext.leavingPhase(ct);
return doBuild(buildConfig, baseHandler, true);
} }
this.handler = this.handler =
CountingMessageHandler.makeCountingMessageHandler(baseHandler); CountingMessageHandler.makeCountingMessageHandler(baseHandler);
if (check != null) { if (check != null) {
if (FAIL_IF_RUNTIME_NOT_FOUND) { if (FAIL_IF_RUNTIME_NOT_FOUND) {
MessageUtil.error(handler, check); MessageUtil.error(handler, check);
CompilationAndWeavingContext.leavingPhase(ct);
return false; return false;
} else { } else {
MessageUtil.warn(handler, check); MessageUtil.warn(handler, check);
initBcelWorld(handler); initBcelWorld(handler);
} }
if (handler.hasErrors()) { if (handler.hasErrors()) {
CompilationAndWeavingContext.leavingPhase(ct);
return false; return false;
} }
if (buildConfig.getOutputJar() != null) { if (buildConfig.getOutputJar() != null) {
if (!openOutputStream(buildConfig.getOutputJar())) return false;
if (!openOutputStream(buildConfig.getOutputJar())) {
CompilationAndWeavingContext.leavingPhase(ct);
return false;
}
} }
if (batch) { if (batch) {
binarySourcesForTheNextCompile = state.getBinaryFilesToCompile(true); binarySourcesForTheNextCompile = state.getBinaryFilesToCompile(true);
performCompilation(buildConfig.getFiles()); performCompilation(buildConfig.getFiles());
if (handler.hasErrors()) { if (handler.hasErrors()) {
CompilationAndWeavingContext.leavingPhase(ct);
return false; return false;
} }


performCompilation(files); performCompilation(files);
if (handler.hasErrors() || (progressListener!=null && progressListener.isCancelledRequested())) { if (handler.hasErrors() || (progressListener!=null && progressListener.isCancelledRequested())) {
CompilationAndWeavingContext.leavingPhase(ct);
return false; return false;
} }
binarySourcesForTheNextCompile = state.getBinaryFilesToCompile(false); binarySourcesForTheNextCompile = state.getBinaryFilesToCompile(false);
AsmManager.getDefault().processDelta(files,state.addedFiles,state.deletedFiles); AsmManager.getDefault().processDelta(files,state.addedFiles,state.deletedFiles);
} }
if (!files.isEmpty()) { if (!files.isEmpty()) {
CompilationAndWeavingContext.leavingPhase(ct);
return batchBuild(buildConfig, baseHandler); return batchBuild(buildConfig, baseHandler);
} else { } else {
if (AsmManager.isReporting()) if (AsmManager.isReporting())
if (buildConfig.isGenerateModelMode()) { if (buildConfig.isGenerateModelMode()) {
AsmManager.getDefault().fireModelUpdated(); AsmManager.getDefault().fireModelUpdated();
} }
CompilationAndWeavingContext.leavingPhase(ct);
} finally { } finally {
CompilationAndWeavingContext.leavingPhase(ct);
if (zos != null) { if (zos != null) {
closeOutputStream(buildConfig.getOutputJar()); closeOutputStream(buildConfig.getOutputJar());
} }

+ 1
- 1
org.aspectj.ajdt.core/src/org/aspectj/tools/ajc/Main.java View File

String m = thrown.getMessage(); String m = thrown.getMessage();
return THROWN_PREFIX return THROWN_PREFIX
+ (null != m ? m + "\n": "") + (null != m ? m + "\n": "")
+ CompilationAndWeavingContext.getCurrentContext()
+ "\n" + CompilationAndWeavingContext.getCurrentContext()
+ LangUtil.renderException(thrown, true); + LangUtil.renderException(thrown, true);
} }

+ 8
- 7
weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java View File

return clazz; return clazz;
} }
} catch (RuntimeException re) { } 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) { } 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)
);
} }
} }

Loading…
Cancel
Save