summaryrefslogtreecommitdiffstats
path: root/bridge/src
diff options
context:
space:
mode:
authorwisberg <wisberg>2004-01-09 07:21:26 +0000
committerwisberg <wisberg>2004-01-09 07:21:26 +0000
commit4b0e98cb1bad527bf18c5d706ae761bb7003e7f3 (patch)
tree4a03753aeb2ea6e3041c5d2cb734523fa6c72cdf /bridge/src
parente683ed8b8b217808f653a3231a56164ef03a689b (diff)
downloadaspectj-4b0e98cb1bad527bf18c5d706ae761bb7003e7f3.tar.gz
aspectj-4b0e98cb1bad527bf18c5d706ae761bb7003e7f3.zip
NPE instead of IAX for null input, clear out unused code, and update test.
Diffstat (limited to 'bridge/src')
-rw-r--r--bridge/src/org/aspectj/bridge/Message.java57
1 files changed, 9 insertions, 48 deletions
diff --git a/bridge/src/org/aspectj/bridge/Message.java b/bridge/src/org/aspectj/bridge/Message.java
index 975d0c70d..69ceb0222 100644
--- a/bridge/src/org/aspectj/bridge/Message.java
+++ b/bridge/src/org/aspectj/bridge/Message.java
@@ -28,19 +28,14 @@ import java.util.List;
* Implement messages.
* This implementation is immutable if ISourceLocation is immutable.
*/
-public class Message implements IMessage { // XXX toString or renderer?
+public class Message implements IMessage {
private final String message;
private final IMessage.Kind kind;
private final Throwable thrown;
private final ISourceLocation sourceLocation;
private final String details;
private final List/*SourceLocation*/ extraSourceLocations;
-
- /** convenience for constructing failure messages */
- public static Message fail(String message, Throwable thrown) {
- return new Message(message, IMessage.FAIL, thrown, null);
- }
-
+
/**
* Create a (compiler) error or warning message
* @param message the String used as the underlying message
@@ -67,20 +62,24 @@ public class Message implements IMessage { // XXX toString or renderer?
public Message(String message, String details, IMessage.Kind kind,
ISourceLocation sourceLocation, Throwable thrown, ISourceLocation[] extraSourceLocations) {
this.details = details;
- this.message = (message==null) ? thrown.getMessage() : message;
+ this.message = ((message!=null) ? message : ((thrown==null) ? null : thrown.getMessage()));
this.kind = kind;
this.sourceLocation = sourceLocation;
this.thrown = thrown;
if (extraSourceLocations != null) {
- this.extraSourceLocations = Arrays.asList(extraSourceLocations);
+ this.extraSourceLocations
+ = Collections.unmodifiableList(Arrays.asList(extraSourceLocations));
}
else {
this.extraSourceLocations = Collections.EMPTY_LIST;
}
- if (null == kind) {
+ if (null == this.kind) {
throw new IllegalArgumentException("null kind");
}
+ if (null == this.message) {
+ throw new IllegalArgumentException("null message");
+ }
}
/**
@@ -97,22 +96,6 @@ public class Message implements IMessage { // XXX toString or renderer?
public Message(String message, IMessage.Kind kind, Throwable thrown,
ISourceLocation sourceLocation) {
this(message, "", kind, sourceLocation, thrown, null );
-// this.message = message;
-// this.kind = kind;
-// this.thrown = thrown;
-// this.sourceLocation = sourceLocation;
-// this.details = "";
-// if (null == message) {
-// if (null != thrown) {
-// message = thrown.getMessage();
-// }
-// if (null == message) {
-// throw new IllegalArgumentException("null message");
-// }
-// }
-// if (null == kind) {
-// throw new IllegalArgumentException("null kind");
-// }
}
/** @return the kind of this message */
@@ -172,28 +155,6 @@ public class Message implements IMessage { // XXX toString or renderer?
public String toString() {
return MessageUtil.renderMessage(this,false);
}
-
-
- public static String render(Throwable thrown) { // XXX cf LangUtil.debugStr
- if (null == thrown) return "null throwable";
- Throwable t = null;
- if (thrown instanceof InvocationTargetException) {
- t = ((InvocationTargetException)thrown).getTargetException();
- } else if (thrown instanceof ClassNotFoundException) {
- t = ((ClassNotFoundException) thrown).getException();
- }
- if (null != t) {
- return render(t);
- }
- StringWriter buf = new StringWriter();
- PrintWriter writer = new PrintWriter(buf);
- writer.println(" Message rendering thrown=" + thrown.getClass().getName());
- writer.println(thrown.getMessage());
- thrown.printStackTrace(writer);
- try { buf.close(); }
- catch (IOException ioe) {}
- return buf.getBuffer().toString();
- }
public String getDetails() {
return details;