diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TThrowable.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TThrowable.java index f947296b9..0bd751f89 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TThrowable.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TThrowable.java @@ -21,10 +21,6 @@ import org.teavm.interop.Remove; import org.teavm.interop.Rename; import org.teavm.interop.Superclass; -/** - * - * @author Alexey Andreev - */ @Superclass("java.lang.Object") public class TThrowable extends RuntimeException { private static final long serialVersionUID = 2026791432677149320L; @@ -115,8 +111,11 @@ public class TThrowable extends RuntimeException { return TString.wrap(getMessage()); } - @Override - public TThrowable getCause() { + @Remove + public native TThrowable getCause(); + + @Rename("getCause") + public TThrowable getCause0() { return cause != this ? cause : null; } diff --git a/tests/src/test/java/org/teavm/classlib/java/lang/ThrowableTest.java b/tests/src/test/java/org/teavm/classlib/java/lang/ThrowableTest.java new file mode 100644 index 000000000..5eed36eef --- /dev/null +++ b/tests/src/test/java/org/teavm/classlib/java/lang/ThrowableTest.java @@ -0,0 +1,32 @@ +/* + * Copyright 2017 Alexey Andreev. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.teavm.classlib.java.lang; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.teavm.junit.TeaVMTestRunner; + +@RunWith(TeaVMTestRunner.class) +public class ThrowableTest { + @Test + public void causeWorks() { + RuntimeException e = new RuntimeException("fail", new RuntimeException("OK")); + assertTrue(e.getCause() instanceof RuntimeException); + assertEquals("OK", e.getCause().getMessage()); + } +}