diff --git a/gwt-core-gwt2-tests/src/test/java/org/gwtproject/core/client/GWTTest.java b/gwt-core-gwt2-tests/src/test/java/org/gwtproject/core/client/GWTTest.java index ef841ed..3d4151e 100644 --- a/gwt-core-gwt2-tests/src/test/java/org/gwtproject/core/client/GWTTest.java +++ b/gwt-core-gwt2-tests/src/test/java/org/gwtproject/core/client/GWTTest.java @@ -45,7 +45,7 @@ public void testReportUncaughtError() { DomGlobal.setTimeout( (ignore) -> { assertEquals(1, caught.size()); - assertEquals("java.lang.JsException", caught.get(0).getClass().getName()); + assertEquals("java.lang.RuntimeException", caught.get(0).getClass().getName()); finishTest(); }, 1000); diff --git a/gwt-core/src/main/java/org/gwtproject/core/client/GWT.java b/gwt-core/src/main/java/org/gwtproject/core/client/GWT.java index 03d7d5d..6ac902a 100644 --- a/gwt-core/src/main/java/org/gwtproject/core/client/GWT.java +++ b/gwt-core/src/main/java/org/gwtproject/core/client/GWT.java @@ -17,6 +17,7 @@ import elemental2.dom.DomGlobal; import elemental2.dom.Window; +import jsinterop.annotations.JsFunction; import jsinterop.annotations.JsMethod; import jsinterop.annotations.JsType; import jsinterop.base.Js; @@ -58,11 +59,10 @@ public static T create(Class clazz) { public static void reportUncaughtException(Throwable e) { // throw an exception "later" so that it ends up handled by the global // error handler. Same code as in GWT2's Impl.reportToBrowser() - DomGlobal.setTimeout( - ignore -> { - throw_(e); - }, - 0); + setTimeout( + () -> { + throw e; + }); } /** @@ -160,8 +160,13 @@ private static class InnerWindow { static Window window; } - @JsMethod(namespace = "", name = "throw") - private static native void throw_(Object object); + @JsFunction + private interface Throwing { + void run() throws Throwable; + } + + @JsMethod(namespace = "", name = "setTimeout") + private static native void setTimeout(Throwing throwingFunction); public static boolean isClient() { return org.gwtproject.core.shared.GWT.isClient();