mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Fix Throwable.toString
This commit is contained in:
parent
acc48f4532
commit
463f24506d
|
@ -134,8 +134,11 @@ public class TThrowable extends RuntimeException {
|
|||
@Remove
|
||||
public native Class<?> getClass0();
|
||||
|
||||
@Remove
|
||||
public native String toString0();
|
||||
@Rename("toString")
|
||||
public String toString0() {
|
||||
String message = getLocalizedMessage();
|
||||
return getClass().getName() + (message != null ? ": " + message : "");
|
||||
}
|
||||
|
||||
public TThrowable initCause(TThrowable cause) {
|
||||
if (this.cause != this && this.cause != null) {
|
||||
|
@ -155,9 +158,9 @@ public class TThrowable extends RuntimeException {
|
|||
|
||||
public void printStackTrace(PrintStream stream) {
|
||||
stream.print(getClass().getName());
|
||||
String message = getMessage();
|
||||
String message = getLocalizedMessage();
|
||||
if (message != null) {
|
||||
stream.print(": " + getMessage());
|
||||
stream.print(": " + message);
|
||||
}
|
||||
stream.println();
|
||||
if (stackTrace != null) {
|
||||
|
@ -173,7 +176,12 @@ public class TThrowable extends RuntimeException {
|
|||
}
|
||||
|
||||
public void printStackTrace(PrintWriter stream) {
|
||||
stream.println(getClass().getName() + ": " + getMessage());
|
||||
stream.print(getClass().getName());
|
||||
String message = getLocalizedMessage();
|
||||
if (message != null) {
|
||||
stream.print(": " + message);
|
||||
}
|
||||
stream.println();
|
||||
if (stackTrace != null) {
|
||||
for (TStackTraceElement element : stackTrace) {
|
||||
stream.print(" at ");
|
||||
|
|
|
@ -29,4 +29,10 @@ public class ThrowableTest {
|
|||
assertTrue(e.getCause() instanceof RuntimeException);
|
||||
assertEquals("OK", e.getCause().getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toStringWorks() {
|
||||
assertEquals("java.lang.RuntimeException: fail", new RuntimeException("fail").toString());
|
||||
assertEquals("java.lang.RuntimeException", new RuntimeException().toString());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user