Skip to content

Commit

Permalink
[GR-44560] Allow calling into the host from polyglot isolate's polygl…
Browse files Browse the repository at this point in the history
…ot thread even when the context is not entered.

PullRequest: graal/13933
  • Loading branch information
jchalou committed Jan 11, 2024
2 parents fd7a710 + 0131220 commit ed2da78
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ed2da78

Please sign in to comment.