]> source.dussan.org Git - aspectj.git/commitdiff
give compilation context on compiler crashes during test case runs
authoracolyer <acolyer>
Thu, 29 Sep 2005 15:40:48 +0000 (15:40 +0000)
committeracolyer <acolyer>
Thu, 29 Sep 2005 15:40:48 +0000 (15:40 +0000)
org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/Ajc.java

index 89c40e1bfe4e7c94cfb0aff9741df8e20fdf24de..9ccf23da079bd90cd9dd4d4d3b367df036bd9317 100644 (file)
@@ -22,10 +22,13 @@ import java.util.StringTokenizer;
 
 import junit.framework.AssertionFailedError;
 
+import org.aspectj.bridge.AbortException;
 import org.aspectj.bridge.ICommand;
 import org.aspectj.bridge.IMessage;
 import org.aspectj.bridge.IMessageHandler;
 import org.aspectj.bridge.MessageHandler;
+import org.aspectj.bridge.IMessage.Kind;
+import org.aspectj.bridge.context.CompilationAndWeavingContext;
 import org.aspectj.util.FileUtil;
 
 /**
@@ -185,6 +188,7 @@ public class Ajc {
                        }
                        args = adjustToSandbox(args,!isIncremental);
                        MessageHandler holder = new MessageHandler();
+                       holder.setInterceptor(new AbortInterceptor());
                        main.setHolder(holder);
                        if (incrementalStage==10 && hasSpecifiedIncremental(args)) {
                          // important to sleep after preparing the sandbox on first incremental stage (see notes in pr90806)
@@ -441,3 +445,27 @@ class AjcCommandController extends Main.CommandController {
                command.repeatCommand(handler);
        }
 }
+
+class AbortInterceptor implements IMessageHandler {
+
+       public boolean handleMessage(IMessage message) throws AbortException {
+               if (message.getKind() == IMessage.ABORT) {
+                       System.err.println("***** Abort Message Received ******");
+                       System.err.println(CompilationAndWeavingContext.getCurrentContext());
+                       System.err.println(message.getMessage());
+                       if (message.getThrown() != null) {
+                               System.err.println("caused by " + message.getThrown().toString());
+                       }
+                       
+               }  // allow message to accumulate... 
+               return false;
+       }
+
+       public boolean isIgnoring(Kind kind) {
+               if (kind != IMessage.ABORT) return true;
+               return false;
+       }
+
+       public void dontIgnore(Kind kind) {
+       }
+}