changeset 22304:7e2abecabcac

Allow to disable Java interoperability
author Christian Wimmer <christian.wimmer@oracle.com>
date Mon, 12 Oct 2015 11:41:22 -0700
parents 1362f35d1f5e
children ae5c160bd047 453f43971ca1
files truffle/com.oracle.truffle.api.vm/src/com/oracle/truffle/api/vm/PolyglotEngine.java
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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 <code>this</code> language.
-         * 
+         *
          * @param source code snippet to execute
          * @return a {@link Value} object that holds result of an execution, never <code>null</code>
          * @throws IOException thrown to signal errors while processing the code