Mercurial > hg > truffle
changeset 22334:c12a7960bd7b
Java interop code reachable without checking JAVA_INITEROP_ENABLED
author | Jaroslav Tulach <jaroslav.tulach@oracle.com> |
---|---|
date | Mon, 02 Nov 2015 09:54:46 +0100 |
parents | 1801b7f11c64 |
children | 906a5f6e07cc |
files | truffle/com.oracle.truffle.api.vm/src/com/oracle/truffle/api/vm/PolyglotEngine.java |
diffstat | 1 files changed, 10 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/truffle/com.oracle.truffle.api.vm/src/com/oracle/truffle/api/vm/PolyglotEngine.java Mon Nov 02 08:58:45 2015 +0100 +++ b/truffle/com.oracle.truffle.api.vm/src/com/oracle/truffle/api/vm/PolyglotEngine.java Mon Nov 02 09:54:46 2015 +0100 @@ -273,16 +273,24 @@ * * @param name name of the symbol to register * @param obj value of the object - expected to be primitive wrapper, {@link String} or - * <code>TruffleObject</code> for mutual inter-operability + * <code>TruffleObject</code> for mutual inter-operability. If the object isn't + * of the previous types, the system tries to wrap it using + * {@link JavaInterop#asTruffleObject(java.lang.Object)}, if available * @return instance of this builder * @see PolyglotEngine#findGlobalSymbol(java.lang.String) + * @throws IllegalArgumentException if the object isn't of primitive type and cannot be + * converted to {@link TruffleObject} */ public Builder globalSymbol(String name, Object obj) { final Object truffleReady; if (obj instanceof Number || obj instanceof String || obj instanceof Character || obj instanceof Boolean) { truffleReady = obj; } else { - truffleReady = JavaInterop.asTruffleObject(obj); + if (JAVA_INTEROP_ENABLED) { + truffleReady = JavaInterop.asTruffleObject(obj); + } else { + throw new IllegalArgumentException(); + } } globals.put(name, truffleReady); return this;