From f50d1eeb894cbd2e5ed8ee619bcdf704e0187ba2 Mon Sep 17 00:00:00 2001 From: ehilsdal Date: Mon, 16 Dec 2002 22:41:15 +0000 Subject: [PATCH] refactoring AbortException to make it clearer when we want to abort w/o message, and to always stuff in a stack trace --- .../org/aspectj/bridge/AbortException.java | 21 ++++++++++++------- .../org/aspectj/bridge/MessageTest.java | 2 +- .../src/org/aspectj/ajdt/ajc/AjdtCommand.java | 4 ++-- .../src/org/aspectj/tools/ajc/Main.java | 2 +- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/bridge/src/org/aspectj/bridge/AbortException.java b/bridge/src/org/aspectj/bridge/AbortException.java index 241b6a8d9..13c63a030 100644 --- a/bridge/src/org/aspectj/bridge/AbortException.java +++ b/bridge/src/org/aspectj/bridge/AbortException.java @@ -38,18 +38,13 @@ import java.util.ArrayList; */ public class AbortException extends RuntimeException { // XXX move porters out, handle proxy better + private boolean isSilent = false; + /** used when message text is null */ public static final String NO_MESSAGE_TEXT = "AbortException (no message)"; private static final ArrayList porters = new ArrayList(); - - /** - * A client may throw this rather than constructing their own - * if stack trace or message is not needed when caught. - */ - public static final AbortException ABORT - = new AbortException("ABORT"); /** * Get a porter exception from the pool. @@ -64,6 +59,7 @@ public class AbortException extends RuntimeException { // XXX move porters out, result = (AbortException) porters.get(0); } else { result = new AbortException(); + result.setIsSilent(false); } } result.setIMessage(message); @@ -106,7 +102,8 @@ public class AbortException extends RuntimeException { // XXX move porters out, /** abort with default String message */ public AbortException() { - this((String) null); + this("ABORT"); + isSilent = true; } /** abort with message */ @@ -222,4 +219,12 @@ public class AbortException extends RuntimeException { // XXX move porters out, } } + public boolean isSilent() { + return isSilent; + } + + public void setIsSilent(boolean isSilent) { + this.isSilent = isSilent; + } + } diff --git a/bridge/testsrc/org/aspectj/bridge/MessageTest.java b/bridge/testsrc/org/aspectj/bridge/MessageTest.java index 6f370eeb3..61488c8ef 100644 --- a/bridge/testsrc/org/aspectj/bridge/MessageTest.java +++ b/bridge/testsrc/org/aspectj/bridge/MessageTest.java @@ -146,7 +146,7 @@ public class MessageTest extends TestCase { // -- throwable kind = IMessage.FAIL; - thrown = AbortException.ABORT; + thrown = new AbortException(); input = null; roundTrip(input, kind, thrown, sl, descriptor, exClass); diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/AjdtCommand.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/AjdtCommand.java index 1cecb4a76..a6c8368fc 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/AjdtCommand.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/AjdtCommand.java @@ -55,7 +55,7 @@ public class AjdtCommand implements ICommand { && buildManager.batchBuild(config, counter) && !counter.hasErrors()); } catch (AbortException ae) { - if (AbortException.ABORT.equals(ae)) { + if (ae.isSilent()) { throw ae; } else { MessageUtil.abort(handler, ABORT_MESSAGE, ae); @@ -107,7 +107,7 @@ public class AjdtCommand implements ICommand { if (null != message) { IMessage.Kind kind = inferKind(message); handler.handleMessage(new Message(message, kind, null, null)); - throw AbortException.ABORT; // XXX tangled - assumes handler prints? + throw new AbortException(); // XXX tangled - assumes handler prints? } return config; } 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 e698d2b40..4c8e684e8 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 @@ -183,7 +183,7 @@ public class Main { } } } catch (AbortException ae) { - if (AbortException.ABORT.equals(ae)) { + if (ae.isSilent()) { quit(); } else { IMessage message = ae.getIMessage(); -- 2.39.5