# HG changeset patch # User Christian Wimmer # Date 1444675282 25200 # Node ID 7e2abecabcac1fc8a3d5ae08d70c1f53b906dbbc # Parent 1362f35d1f5e7f1620f3440ce3b104693685a93b Allow to disable Java interoperability diff -r 1362f35d1f5e -r 7e2abecabcac truffle/com.oracle.truffle.api.vm/src/com/oracle/truffle/api/vm/PolyglotEngine.java --- a/truffle/com.oracle.truffle.api.vm/src/com/oracle/truffle/api/vm/PolyglotEngine.java Mon Oct 12 12:56:20 2015 -0400 +++ b/truffle/com.oracle.truffle.api.vm/src/com/oracle/truffle/api/vm/PolyglotEngine.java Mon Oct 12 11:41:22 2015 -0700 @@ -103,6 +103,8 @@ */ @SuppressWarnings("rawtypes") public class PolyglotEngine { + static final boolean JAVA_INTEROP_ENABLED = !Boolean.getBoolean("com.oracle.truffle.aot"); + static final Logger LOG = Logger.getLogger(PolyglotEngine.class.getName()); private static final SPIAccessor SPI = new SPIAccessor(); private final Thread initThread; @@ -733,7 +735,10 @@ if (representation.isInstance(obj)) { return representation.cast(obj); } - return JavaInterop.asJavaObject(representation, (TruffleObject) obj); + if (JAVA_INTEROP_ENABLED) { + return JavaInterop.asJavaObject(representation, (TruffleObject) obj); + } + throw new IllegalArgumentException("Value cannot be represented as " + representation.getName()); } /** @@ -863,7 +868,7 @@ /** * Evaluates provided source. Ignores the particular {@link Source#getMimeType() MIME type} * and forces evaluation in the context of this language. - * + * * @param source code snippet to execute * @return a {@link Value} object that holds result of an execution, never null * @throws IOException thrown to signal errors while processing the code