diff --git a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/PolyglotThreadNotificationsTest.java b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/PolyglotThreadNotificationsTest.java index 7d8b400f9296..fc4d5844f3b2 100644 --- a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/PolyglotThreadNotificationsTest.java +++ b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/PolyglotThreadNotificationsTest.java @@ -591,9 +591,6 @@ protected boolean isThreadAccessAllowed(Thread thread, boolean singleThreaded) { @Test public void testThreadNotificationError() throws IOException { - // TODO GR-44560 - TruffleTestAssumptions.assumeWeakEncapsulation(); - try (ByteArrayOutputStream errorOutput = new ByteArrayOutputStream(); Context ctx = Context.newBuilder().allowCreateThread(true).err(errorOutput).build()) { AbstractExecutableTestLanguage.evalTestLanguage(ctx, ThreadNotificationErrorTestLanguage.class, "1", "throwBefore"); AbstractExecutableTestLanguage.evalTestLanguage(ctx, ThreadNotificationErrorTestLanguage.class, "2", "throwAfter"); diff --git a/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotLanguageContext.java b/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotLanguageContext.java index 4dd8670fc6b6..0947a18c402b 100644 --- a/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotLanguageContext.java +++ b/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotLanguageContext.java @@ -56,6 +56,7 @@ import java.util.Set; import java.util.logging.Level; +import org.graalvm.polyglot.impl.AbstractPolyglotImpl; import org.graalvm.polyglot.impl.AbstractPolyglotImpl.APIAccess; import com.oracle.truffle.api.CallTarget; @@ -1010,12 +1011,13 @@ public String toString() { private class PolyglotUncaughtExceptionHandler implements Thread.UncaughtExceptionHandler { + @SuppressWarnings({"unused", "try"}) @Override public void uncaughtException(Thread t, Throwable e) { if (!(e instanceof ThreadDeath)) { Env currentEnv = env; if (currentEnv != null) { - try { + try (AbstractPolyglotImpl.ThreadScope scope = PolyglotLanguageContext.this.getImpl().getRootImpl().createThreadScope()) { e.printStackTrace(new PrintStream(currentEnv.err())); } catch (Throwable exc) { // Still show the original error if printing on Env.err() fails for some