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 7c72f80aa..428d2a588 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 @@ -22,7 +22,6 @@ import org.teavm.classlib.java.util.TArrays; import org.teavm.interop.Remove; import org.teavm.interop.Rename; import org.teavm.interop.Superclass; -import org.teavm.interop.Unmanaged; import org.teavm.runtime.ExceptionHandling; @Superclass("java.lang.Object") @@ -104,16 +103,11 @@ public class TThrowable extends RuntimeException { @Override public Throwable fillInStackTrace() { if (PlatformDetector.isLowLevel()) { - stackTrace = fillInStackTraceLowLevel(); + stackTrace = (TStackTraceElement[]) (Object) ExceptionHandling.fillStackTrace(); } return this; } - @Unmanaged - private static TStackTraceElement[] fillInStackTraceLowLevel() { - return (TStackTraceElement[]) (Object) ExceptionHandling.fillStackTrace(); - } - @Rename("getMessage") public String getMessage0() { return message; diff --git a/core/src/main/java/org/teavm/model/lowlevel/ExceptionHandlingShadowStackContributor.java b/core/src/main/java/org/teavm/model/lowlevel/ExceptionHandlingShadowStackContributor.java index 592d20372..4979946f9 100644 --- a/core/src/main/java/org/teavm/model/lowlevel/ExceptionHandlingShadowStackContributor.java +++ b/core/src/main/java/org/teavm/model/lowlevel/ExceptionHandlingShadowStackContributor.java @@ -67,6 +67,8 @@ import org.teavm.runtime.ExceptionHandling; import org.teavm.runtime.ShadowStack; public class ExceptionHandlingShadowStackContributor { + private static final MethodReference FILL_STACK_TRACE = new MethodReference(ExceptionHandling.class, + "fillStackTrace", StackTraceElement[].class); private Characteristics characteristics; private List callSites; private BasicBlock defaultExceptionHandler; @@ -281,7 +283,11 @@ public class ExceptionHandlingShadowStackContributor { || insn instanceof NullCheckInstruction || insn instanceof BoundCheckInstruction) { return true; } else if (insn instanceof InvokeInstruction) { - return isManagedMethodCall(characteristics, ((InvokeInstruction) insn).getMethod()); + MethodReference method = ((InvokeInstruction) insn).getMethod(); + if (method.equals(FILL_STACK_TRACE)) { + return true; + } + return isManagedMethodCall(characteristics, method); } return false; }