From 46dba28e4501641e1dc5972ca3d32f3ea9a3fbcc Mon Sep 17 00:00:00 2001 From: Tomas Zezula Date: Mon, 26 Feb 2024 14:31:59 +0100 Subject: [PATCH] [GR-52328] Improve an error message when a polyglot goes not support the requested sandbox policy. --- .../truffle/api/test/polyglot/SandboxPolicyTest.java | 2 +- .../src/com/oracle/truffle/polyglot/PolyglotImpl.java | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/SandboxPolicyTest.java b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/SandboxPolicyTest.java index e5c24599690a..12eefbb3f509 100644 --- a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/SandboxPolicyTest.java +++ b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/SandboxPolicyTest.java @@ -85,7 +85,7 @@ public class SandboxPolicyTest { private static final String MISSING_ISOLATE_LIBRARY_MESSAGE = "No native isolate library found for language"; - private static final String UNSUPPORTED_ISOLATE_POLICY_MESSAGE = "the GraalVM community edition supports only sandbox policy TRUSTED or CONSTRAINED."; + private static final String UNSUPPORTED_ISOLATE_POLICY_MESSAGE = "but the current Truffle runtime only supports the TRUSTED or CONSTRAINED sandbox policies."; private final Configuration configuration; diff --git a/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotImpl.java b/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotImpl.java index 08b36fdd3864..bf1d2b8d8107 100644 --- a/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotImpl.java +++ b/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/PolyglotImpl.java @@ -415,8 +415,11 @@ private void validateSandbox(SandboxPolicy sandboxPolicy) { // all sandboxing policies. if (this == getRootImpl() && sandboxPolicy.isStricterThan(SandboxPolicy.CONSTRAINED)) { throw PolyglotEngineException.illegalArgument(String.format( - "The Builder.sandbox(SandboxPolicy) is set to %s, but the GraalVM community edition supports only sandbox policy TRUSTED or CONSTRAINED." + - "In order to resolve this switch to a less strict sandbox policy using Builder.sandbox(SandboxPolicy).", + "The Builder.sandbox(SandboxPolicy) is configured to %s, but the current Truffle runtime only supports the TRUSTED or CONSTRAINED sandbox policies. " + + "This typically occurs when a non-Oracle GraalVM Java runtime is used, the org.graalvm.truffle:truffle-enterprise dependency is missing, or the fallback runtime was forced. " + + "The Truffle fallback runtime may be forced using the truffle.UseFallbackRuntime or truffle.TruffleRuntime system property. " + + "To resolve this make sure Oracle GraalVM is used, the truffle-enterprise dependency is on the class or module path and the fallback runtime is not forced. " + + "Alternatively, you can switch to a less strict sandbox policy using Builder.sandbox(SandboxPolicy).", sandboxPolicy)); } }