From 819588546e58502d6e00d8d5dc081c0296d9bb3f Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Mon, 21 Apr 2008 16:30:41 -0600 Subject: [PATCH] implement a few StackTraceElement methods --- classpath/java/lang/StackTraceElement.java | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/classpath/java/lang/StackTraceElement.java b/classpath/java/lang/StackTraceElement.java index c26db301f5..f20dc27803 100644 --- a/classpath/java/lang/StackTraceElement.java +++ b/classpath/java/lang/StackTraceElement.java @@ -27,6 +27,34 @@ public class StackTraceElement { this.line = line; } + public int hashCode() { + return class_.hashCode() ^ method.hashCode() ^ line; + } + + public boolean equals(Object o) { + if (o instanceof StackTraceElement) { + StackTraceElement e = (StackTraceElement) o; + return class_.equals(e.class_) + && method.equals(e.method) + && line == e.line; + } else { + return false; + } + } + + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(class_).append(".").append(method); + + if (line == NativeLine) { + sb.append(" (native)"); + } else if (line >= 0) { + sb.append(" (line ").append(line).append(")"); + } + + return sb.toString(); + } + public String getClassName() { return class_; }