From e810fb7df3381b63e1257d1cd5f95bd7095fae9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Wa=C5=9Bko?= Date: Wed, 6 Sep 2023 19:05:09 +0200 Subject: [PATCH 1/2] Fix #7359 by throwing `UnsupportedMessageException` as required by the `InteropLibrary` --- .../api/exception/DefaultStackTraceElementObject.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.exception/src/com/oracle/truffle/api/exception/DefaultStackTraceElementObject.java b/truffle/src/com.oracle.truffle.api.exception/src/com/oracle/truffle/api/exception/DefaultStackTraceElementObject.java index 2d8249efda3e..953a7aa45da1 100644 --- a/truffle/src/com.oracle.truffle.api.exception/src/com/oracle/truffle/api/exception/DefaultStackTraceElementObject.java +++ b/truffle/src/com.oracle.truffle.api.exception/src/com/oracle/truffle/api/exception/DefaultStackTraceElementObject.java @@ -69,8 +69,12 @@ boolean hasExecutableName() { @ExportMessage @TruffleBoundary - Object getExecutableName() { - return rootNode.getName(); + Object getExecutableName() throws UnsupportedMessageException { + String name = rootNode.getName(); + if (name == null) { + throw UnsupportedMessageException.create(); + } + return name; } @ExportMessage From bb108fa60bf726c0bd628115164df01c8cddc8ae Mon Sep 17 00:00:00 2001 From: Jakub Chaloupka Date: Thu, 14 Sep 2023 16:25:53 +0200 Subject: [PATCH 2/2] Add test. --- .../src/com/oracle/truffle/api/test/RootNodeTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/RootNodeTest.java b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/RootNodeTest.java index 006f8c588d94..9686979ef680 100644 --- a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/RootNodeTest.java +++ b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/RootNodeTest.java @@ -264,6 +264,8 @@ static void verifyStackTraceElementGuestObject(Object guestObject) throws Unsupp if (interop.hasExecutableName(guestObject)) { Object executableName = interop.getExecutableName(guestObject); Assert.assertTrue(interop.isString(executableName)); + } else { + AbstractPolyglotTest.assertFails(() -> interop.getExecutableName(guestObject), UnsupportedMessageException.class); } if (interop.hasDeclaringMetaObject(guestObject)) { Object metaObject = interop.getDeclaringMetaObject(guestObject);