diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/BasePackage.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/BasePackage.java index 2030c3ecb77f0d70debd5bc68b326daa7d802d3c..9d55e2b44f1b2c1458e0db9300e163bfe05c36f5 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/BasePackage.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/BasePackage.java @@ -376,6 +376,7 @@ public class BasePackage extends RBuiltinPackage { add(FastRInterop.InteropNew.class, FastRInteropFactory.InteropNewNodeGen::create); add(FastRInterop.IsNull.class, FastRInteropFactory.IsNullNodeGen::create); add(FastRInterop.IsExecutable.class, FastRInteropFactory.IsExecutableNodeGen::create); + add(FastRInterop.IsExternal.class, FastRInteropFactory.IsExternalNodeGen::create); add(FastRInterop.JavaClass.class, FastRInteropFactory.JavaClassNodeGen::create); add(FastRInterop.IsJavaArray.class, FastRInteropFactory.IsJavaArrayNodeGen::create); add(FastRInterop.NewJavaArray.class, FastRInteropFactory.NewJavaArrayNodeGen::create); diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/IsFiniteFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/IsFiniteFunctions.java index 075d0dbb0345c8a8fbb981fac42b4732aa436adb..501d4a283f10f8a9cddbee1d34879ff4cc9c8de8 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/IsFiniteFunctions.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/IsFiniteFunctions.java @@ -31,7 +31,9 @@ import java.util.function.IntPredicate; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.ImportStatic; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.interop.TruffleObject; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetDimAttributeNode; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetNamesAttributeNode; import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; @@ -53,6 +55,7 @@ import com.oracle.truffle.r.runtime.data.model.RAbstractVector; public class IsFiniteFunctions { + @ImportStatic(RRuntime.class) public abstract static class Adapter extends RBuiltinNode.Arg1 { @Child private GetDimAttributeNode getDims = GetDimAttributeNode.create(); @@ -83,6 +86,12 @@ public class IsFiniteFunctions { return doFunConstant(x, RRuntime.LOGICAL_FALSE); } + @Specialization(guards = "isForeignObject(obj)") + @TruffleBoundary + protected byte doIsForeign(@SuppressWarnings("unused") TruffleObject obj) { + throw error(RError.Message.DEFAULT_METHOD_NOT_IMPLEMENTED_FOR_TYPE, "external object"); + } + @Fallback @TruffleBoundary protected Object doIsFiniteOther(Object x) { diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/IsNA.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/IsNA.java index c08de1b1f10abdba38904bb6e90c461d64b64727..166728e6642771dc131f3944539d2638e4ad2bc0 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/IsNA.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/IsNA.java @@ -29,7 +29,9 @@ import static com.oracle.truffle.r.runtime.builtins.RBuiltinKind.PRIMITIVE; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.ImportStatic; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.interop.TruffleObject; import com.oracle.truffle.api.profiles.ConditionProfile; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetDimAttributeNode; import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetDimNamesAttributeNode; @@ -53,6 +55,7 @@ import com.oracle.truffle.r.runtime.data.model.RAbstractDoubleVector; import com.oracle.truffle.r.runtime.data.model.RAbstractIntVector; import com.oracle.truffle.r.runtime.data.model.RAbstractVector; +@ImportStatic(RRuntime.class) @RBuiltin(name = "is.na", kind = PRIMITIVE, parameterNames = {"x"}, dispatch = INTERNAL_GENERIC, behavior = PURE) public abstract class IsNA extends RBuiltinNode.Arg1 { @@ -195,6 +198,11 @@ public abstract class IsNA extends RBuiltinNode.Arg1 { return RDataFactory.createEmptyLogicalVector(); } + @Specialization(guards = "isForeignObject(obj)") + protected byte isNA(@SuppressWarnings("unused") TruffleObject obj) { + return RRuntime.LOGICAL_FALSE; + } + // Note: all the primitive values have specialization, so we can only get RTypedValue in // fallback @Fallback diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/IsTypeFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/IsTypeFunctions.java index 74152f23bf2199922819321a77e4e70350476f6c..f966c9ab3c357134731cfa5fa331f6379f3c94ce 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/IsTypeFunctions.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/IsTypeFunctions.java @@ -31,7 +31,9 @@ import static com.oracle.truffle.r.runtime.builtins.RBuiltinKind.PRIMITIVE; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.ImportStatic; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.interop.TruffleObject; import com.oracle.truffle.api.object.DynamicObject; import com.oracle.truffle.api.profiles.ConditionProfile; import com.oracle.truffle.r.nodes.attributes.GetFixedAttributeNode; @@ -100,6 +102,7 @@ public class IsTypeFunctions { } } + @ImportStatic(RRuntime.class) @RBuiltin(name = "is.recursive", kind = PRIMITIVE, parameterNames = {"x"}, behavior = PURE) public abstract static class IsRecursive extends MissingAdapter { @@ -126,6 +129,11 @@ public class IsTypeFunctions { return arg instanceof RListBase; } + @Specialization(guards = "isForeignObject(obj)") + protected byte isRecursive(@SuppressWarnings("unused") TruffleObject obj) { + return RRuntime.LOGICAL_FALSE; + } + @Fallback protected byte isRecursiveFallback(@SuppressWarnings("unused") Object value) { return RRuntime.LOGICAL_TRUE; diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/FastRInterop.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/FastRInterop.java index 0857f0b53170e67e2b6042ce574718bad030cbff..4c2f44c65435784378c9ac91b3fb8e3f55df718b 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/FastRInterop.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/FastRInterop.java @@ -53,6 +53,7 @@ import com.oracle.truffle.api.interop.java.JavaInterop; import com.oracle.truffle.api.nodes.DirectCallNode; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.ValueProfile; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.source.Source.Builder; import com.oracle.truffle.r.nodes.builtin.CastBuilder.Predef; @@ -92,6 +93,12 @@ import java.util.logging.Logger; public class FastRInterop { + private static boolean isTesting = false; + + public static void testingMode() { + isTesting = true; + } + @RBuiltin(name = ".fastr.interop.eval", visibility = OFF, kind = PRIMITIVE, parameterNames = {"mimeType", "source"}, behavior = COMPLEX) public abstract static class Eval extends RBuiltinNode.Arg2 { @@ -420,26 +427,31 @@ public class FastRInterop { } } - @RBuiltin(name = ".fastr.java.class", visibility = ON, kind = PRIMITIVE, parameterNames = {"class"}, behavior = COMPLEX) - public abstract static class JavaClass extends RBuiltinNode.Arg1 { + @RBuiltin(name = ".fastr.java.class", visibility = ON, kind = PRIMITIVE, parameterNames = {"class", "silent"}, behavior = COMPLEX) + public abstract static class JavaClass extends RBuiltinNode.Arg2 { static { Casts casts = new Casts(JavaClass.class); casts.arg("class").mustBe(stringValue()).asStringVector().mustBe(Predef.singleElement()).findFirst(); + casts.arg("silent").mapMissing(Predef.constant(RRuntime.LOGICAL_FALSE)).mustBe(logicalValue().or(Predef.nullValue())).asLogicalVector().mustBe(singleElement()).findFirst().mustBe( + notLogicalNA()).map(Predef.toBoolean()); } @Specialization @TruffleBoundary - public TruffleObject javaClass(String clazz) { + public TruffleObject javaClass(String clazz, boolean silent) { try { - return JavaInterop.asTruffleObject(Class.forName(clazz)); + return JavaInterop.asTruffleObject(Class.forName(clazz.replaceAll("/", "."))); } catch (ClassNotFoundException | SecurityException | IllegalArgumentException e) { + if (silent) { + return RNull.instance; + } throw error(RError.Message.GENERIC, "error while accessing Java class: " + e.getMessage()); } } } - @ImportStatic({Message.class, RRuntime.class}) + @ImportStatic({RRuntime.class}) @RBuiltin(name = ".fastr.java.isArray", visibility = ON, kind = PRIMITIVE, parameterNames = {"obj"}, behavior = COMPLEX) public abstract static class IsJavaArray extends RBuiltinNode.Arg1 { @@ -506,7 +518,7 @@ public class FastRInterop { Casts casts = new Casts(ToJavaArray.class); casts.arg("x").mustNotBeMissing(); casts.arg("className").allowMissing().mustBe(stringValue()).asStringVector().mustBe(Predef.singleElement()).findFirst(); - casts.arg("flat").mapMissing(Predef.constant(RRuntime.asLogical(true))).mustBe(logicalValue().or(Predef.nullValue())).asLogicalVector().mustBe(singleElement()).findFirst().mustBe( + casts.arg("flat").mapMissing(Predef.constant(RRuntime.LOGICAL_TRUE)).mustBe(logicalValue().or(Predef.nullValue())).asLogicalVector().mustBe(singleElement()).findFirst().mustBe( notLogicalNA()).map(Predef.toBoolean()); } @@ -796,8 +808,9 @@ public class FastRInterop { } Object result = ForeignAccess.sendNew(sendNew, clazz, argValues); return RRuntime.java2R(result); - } catch (SecurityException | IllegalArgumentException | UnsupportedTypeException | ArityException | UnsupportedMessageException e) { - throw error(RError.Message.GENERIC, "error during Java object instantiation: " + e.getMessage()); + } catch (IllegalStateException | SecurityException | IllegalArgumentException | UnsupportedTypeException | ArityException | UnsupportedMessageException e) { + String msg = isTesting ? "error during Java object instantiation" : "error during Java object instantiation: " + e.getMessage(); + throw error(RError.Message.GENERIC, msg); } } @@ -806,4 +819,23 @@ public class FastRInterop { throw error(RError.Message.GENERIC, "interop object needed as receiver of NEW message"); } } + + @ImportStatic(RRuntime.class) + @RBuiltin(name = ".fastr.interop.isExternal", visibility = ON, kind = PRIMITIVE, parameterNames = {"obj"}, behavior = COMPLEX) + public abstract static class IsExternal extends RBuiltinNode.Arg1 { + + static { + Casts.noCasts(IsExternal.class); + } + + @Specialization(guards = {"isForeignObject(obj)"}) + public byte isExternal(TruffleObject obj) { + return RRuntime.LOGICAL_TRUE; + } + + @Fallback + public byte isExternal(Object obj) { + return RRuntime.LOGICAL_FALSE; + } + } } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/methods/R/methods_overrides.R b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/methods/R/methods_overrides.R index 99c947a62dbc8ce4e07359f7873abf9baab63558..698ae85bc701c39fe45b7d6ae8f35fcd75ae7345 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/methods/R/methods_overrides.R +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/methods/R/methods_overrides.R @@ -23,4 +23,20 @@ eval(expression({ # this function is replaced with a primitive because it is expected to # modify its argument in-place, which can clash with argument refcount handling `slot<-` <- .fastr.methods.slotassign + +new <- function (Class, ...) { + if(is.character(Class)) { + javaClass <- .fastr.java.class(Class, silent=TRUE) + if(!is.null(javaClass)) { + Class <- javaClass + } + } + if(.fastr.interop.isExternal(Class)) { + .fastr.interop.new(Class, ...) + } else { + ClassDef <- getClass(Class, where = topenv(parent.frame())) + value <- .Call(C_new_object, ClassDef) + initialize(value, ...) + } +} }), asNamespace("methods")) diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/TypeofNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/TypeofNode.java index 1df443ba8c97ea0df8b9b11c2f42a9540d0b1608..c2e606b1f73a542fce854d221e417ee5848b8d36 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/TypeofNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/TypeofNode.java @@ -62,6 +62,11 @@ public abstract class TypeofNode extends UnaryNode { return RType.Missing; } + @Specialization(guards = "isForeignObject(object)") + protected RType doTruffleObject(@SuppressWarnings("unused") TruffleObject object) { + return RType.TruffleObject; + } + @Specialization(guards = {"operand.getClass() == cachedClass"}, limit = "NUMBER_OF_CACHED_CLASSES") protected static RType doCachedTyped(Object operand, @Cached("getTypedValueClass(operand)") Class<? extends RTypedValue> cachedClass) { @@ -82,11 +87,6 @@ public abstract class TypeofNode extends UnaryNode { return operand.getRType(); } - @Specialization(guards = "isForeignObject(object)") - protected RType doTruffleObject(@SuppressWarnings("unused") TruffleObject object) { - return RType.TruffleObject; - } - protected static boolean isForeignObject(Object obj) { return RRuntime.isForeignObject(obj); } diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test index 5a21cdda8a00bd854d68f8860b6a5867fe362d7c..a4a69155cacaecab5a2c1cd3f99735e0c92629e9 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test @@ -131076,25 +131076,228 @@ NULL NULL -##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIdentical# -#if (length(grep("FastR", R.Version()$version.string)) != 1) { FALSE } else { b1 <- .fastr.interop.toByte(1); b2 <- .fastr.interop.toByte(1); identical(b1, b2) } +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testInteroptNew# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { 'a' } else { tc <- .fastr.java.class('java.lang.Character'); t <- .fastr.interop.new(tc, .fastr.interop.toChar(97)); t } +[1] "a" + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testInteroptNew# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { 'abc' } else { tc <- .fastr.java.class('java.lang.String'); t <- .fastr.interop.new(tc, 'abc'); t } +[1] "abc" + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testInteroptNew# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { 'truffle.object' } else { tc <- .fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestNullClass'); t <- .fastr.interop.new(tc, NULL); class(t) } +[1] "truffle.object" + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testInteroptNew# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { 1 } else { tc <- .fastr.java.class('java.lang.Byte'); t <- .fastr.interop.new(tc, .fastr.interop.toByte(1)); t } +[1] 1 + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testInteroptNew# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { 1 } else { tc <- .fastr.java.class('java.lang.Integer'); t <- .fastr.interop.new(tc, 1L); t } +[1] 1 + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testInteroptNew# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { 1 } else { tc <- .fastr.java.class('java.lang.Long'); t <- .fastr.interop.new(tc, .fastr.interop.toLong(1)); t } +[1] 1 + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testInteroptNew# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { 1 } else { tc <- .fastr.java.class('java.lang.Short'); t <- .fastr.interop.new(tc, .fastr.interop.toShort(1)); t } +[1] 1 + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testInteroptNew# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { 1.1 } else { tc <- .fastr.java.class('java.lang.Double'); t <- .fastr.interop.new(tc, 1.1); t } +[1] 1.1 + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testInteroptNew# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { 1.1 } else { tc <- .fastr.java.class('java.lang.Float'); t <- .fastr.interop.new(tc, .fastr.interop.toFloat(1.1)); t } +[1] 1.1 + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testInteroptNew# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { TRUE } else { tc <- .fastr.java.class('java.lang.Boolean'); t <- .fastr.interop.new(tc, TRUE); t } +[1] TRUE + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testInteroptNew# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { TRUE } else { tc <- .fastr.java.class('java/lang/Boolean'); t <- new(tc, TRUE); t } +[1] TRUE + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIsXXXForForeignObject# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { FALSE } else { to <- .fastr.interop.new(.fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); is.array(to) } [1] FALSE -##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIdentical# -#if (length(grep("FastR", R.Version()$version.string)) != 1) { FALSE } else { b1 <- .fastr.interop.toByte(1); s1 <- .fastr.interop.toShort(1); identical(b1, s1) } +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIsXXXForForeignObject# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { FALSE } else { to <- .fastr.interop.new(.fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); is.atomic(to) } [1] FALSE -##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIdentical# -#if (length(grep("FastR", R.Version()$version.string)) != 1) { FALSE } else { ll <- .fastr.interop.new(.fastr.java.class('java.util.LinkedList')); al <- .fastr.interop.new(.fastr.java.class('java.util.ArrayList')); identical(al, ll) } +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIsXXXForForeignObject# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { FALSE } else { to <- .fastr.interop.new(.fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); is.call(to) } [1] FALSE -##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIdentical# -#if (length(grep("FastR", R.Version()$version.string)) != 1) { TRUE } else { al <- .fastr.interop.new(.fastr.java.class('java.util.ArrayList')); identical(t, t) } -[1] TRUE +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIsXXXForForeignObject# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { FALSE } else { to <- .fastr.interop.new(.fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); is.character(to) } +[1] FALSE -##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIdentical# -#if (length(grep("FastR", R.Version()$version.string)) != 1) { TRUE } else { b1 <- .fastr.interop.toByte(1); identical(b1, b1) } -[1] TRUE +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIsXXXForForeignObject# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { FALSE } else { to <- .fastr.interop.new(.fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); is.complex(to) } +[1] FALSE + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIsXXXForForeignObject# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { FALSE } else { to <- .fastr.interop.new(.fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); is.data.frame(to) } +[1] FALSE + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIsXXXForForeignObject# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { FALSE } else { to <- .fastr.interop.new(.fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); is.double(to) } +[1] FALSE + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIsXXXForForeignObject# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { FALSE } else { to <- .fastr.interop.new(.fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); is.environment(to) } +[1] FALSE + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIsXXXForForeignObject# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { FALSE } else { to <- .fastr.interop.new(.fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); is.expression(to) } +[1] FALSE + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIsXXXForForeignObject# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { FALSE } else { to <- .fastr.interop.new(.fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); is.factor(to) } +[1] FALSE + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIsXXXForForeignObject# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { FALSE } else { to <- .fastr.interop.new(.fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); is.function(to) } +[1] FALSE + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIsXXXForForeignObject# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { FALSE } else { to <- .fastr.interop.new(.fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); is.integer(to) } +[1] FALSE + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIsXXXForForeignObject# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { FALSE } else { to <- .fastr.interop.new(.fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); is.language(to) } +[1] FALSE + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIsXXXForForeignObject# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { FALSE } else { to <- .fastr.interop.new(.fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); is.logical(to) } +[1] FALSE + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIsXXXForForeignObject# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { FALSE } else { to <- .fastr.interop.new(.fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); is.matrix(to) } +[1] FALSE + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIsXXXForForeignObject# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { FALSE } else { to <- .fastr.interop.new(.fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); is.mts(to) } +[1] FALSE + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIsXXXForForeignObject# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { FALSE } else { to <- .fastr.interop.new(.fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); is.na(to) } +[1] FALSE + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIsXXXForForeignObject# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { FALSE } else { to <- .fastr.interop.new(.fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); is.name(to) } +[1] FALSE + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIsXXXForForeignObject# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { FALSE } else { to <- .fastr.interop.new(.fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); is.null(to) } +[1] FALSE + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIsXXXForForeignObject# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { FALSE } else { to <- .fastr.interop.new(.fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); is.numeric(to) } +[1] FALSE + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIsXXXForForeignObject# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { FALSE } else { to <- .fastr.interop.new(.fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); is.numeric.Date(to) } +[1] FALSE + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIsXXXForForeignObject# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { FALSE } else { to <- .fastr.interop.new(.fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); is.numeric.POSIXt(to) } +[1] FALSE + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIsXXXForForeignObject# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { FALSE } else { to <- .fastr.interop.new(.fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); is.numeric.difftime(to) } +[1] FALSE + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIsXXXForForeignObject# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { FALSE } else { to <- .fastr.interop.new(.fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); is.numeric_version(to) } +[1] FALSE + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIsXXXForForeignObject# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { FALSE } else { to <- .fastr.interop.new(.fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); is.object(to) } +[1] FALSE + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIsXXXForForeignObject# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { FALSE } else { to <- .fastr.interop.new(.fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); is.ordered(to) } +[1] FALSE + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIsXXXForForeignObject# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { FALSE } else { to <- .fastr.interop.new(.fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); is.package_version(to) } +[1] FALSE + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIsXXXForForeignObject# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { FALSE } else { to <- .fastr.interop.new(.fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); is.pairlist(to) } +[1] FALSE + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIsXXXForForeignObject# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { FALSE } else { to <- .fastr.interop.new(.fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); is.primitive(to) } +[1] FALSE + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIsXXXForForeignObject# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { FALSE } else { to <- .fastr.interop.new(.fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); is.qr(to) } +[1] FALSE + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIsXXXForForeignObject# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { FALSE } else { to <- .fastr.interop.new(.fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); is.raster(to) } +[1] FALSE + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIsXXXForForeignObject# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { FALSE } else { to <- .fastr.interop.new(.fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); is.raw(to) } +[1] FALSE + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIsXXXForForeignObject# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { FALSE } else { to <- .fastr.interop.new(.fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); is.recursive(to) } +[1] FALSE + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIsXXXForForeignObject# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { FALSE } else { to <- .fastr.interop.new(.fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); is.relistable(to) } +[1] FALSE + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIsXXXForForeignObject# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { FALSE } else { to <- .fastr.interop.new(.fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); is.stepfun(to) } +[1] FALSE + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIsXXXForForeignObject# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { FALSE } else { to <- .fastr.interop.new(.fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); is.symbol(to) } +[1] FALSE + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIsXXXForForeignObject# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { FALSE } else { to <- .fastr.interop.new(.fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); is.table(to) } +[1] FALSE + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIsXXXForForeignObject# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { FALSE } else { to <- .fastr.interop.new(.fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); is.ts(to) } +[1] FALSE + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIsXXXForForeignObject# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { FALSE } else { to <- .fastr.interop.new(.fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); is.tskernel(to) } +[1] FALSE + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIsXXXForForeignObject# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { FALSE } else { to <- .fastr.interop.new(.fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); is.unsorted(to) } +[1] FALSE + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIsXXXForForeignObject# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { FALSE } else { to <- .fastr.interop.new(.fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); is.vector(to) } +[1] FALSE + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIsXXXForForeignObject# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { cat('Error in is.finite(to) : ', '<<<NEWLINE>>>', ' default method not implemented for type \'external object\'<<<NEWLINE>>>', sep='') } else { to <- .fastr.interop.new(.fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); is.finite(to) } +Error in is.finite(to) : + default method not implemented for type 'external object' + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIsXXXForForeignObject# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { cat('Error in is.infinite(to) : ', '<<<NEWLINE>>>', ' default method not implemented for type \'external object\'<<<NEWLINE>>>', sep='') } else { to <- .fastr.interop.new(.fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); is.infinite(to) } +Error in is.infinite(to) : + default method not implemented for type 'external object' + +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testIsXXXForForeignObject# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { cat('Error in is.nan(to) : ', '<<<NEWLINE>>>', ' default method not implemented for type \'external object\'<<<NEWLINE>>>', sep='') } else { to <- .fastr.interop.new(.fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass')); is.nan(to) } +Error in is.nan(to) : + default method not implemented for type 'external object' ##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testMethods# #if (length(grep("FastR", R.Version()$version.string)) != 1) { "a string" } else { tc <- .fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass'); t <- .fastr.interop.new(tc); t$methodStaticStringObject() } @@ -131260,77 +131463,67 @@ NULL [external object] [1] 1 2 3 -##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testNamesForJavaObject# +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testNamesForForeignObject# #if (length(grep("FastR", R.Version()$version.string)) != 1) { NULL } else { cl <- .fastr.java.class('java.util.Collections'); em<-cl$EMPTY_MAP; names(em) } NULL -##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testNamesForJavaObject# +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testNamesForForeignObject# #if (length(grep("FastR", R.Version()$version.string)) != 1) { NULL } else { tc <- .fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestNamesClass'); names(tc$staticField) } NULL -##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testNamesForJavaObject# +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testNamesForForeignObject# #if (length(grep("FastR", R.Version()$version.string)) != 1) { NULL } else { tc <- .fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestNamesClass'); names(tc$staticMethod) } NULL -##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testNamesForJavaObject# +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testNamesForForeignObject# #if (length(grep("FastR", R.Version()$version.string)) != 1) { NULL } else { tc <- .fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestNamesClassNoMembers'); t <- .fastr.interop.new(tc); names(t) } NULL -##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testNamesForJavaObject# +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testNamesForForeignObject# #if (length(grep("FastR", R.Version()$version.string)) != 1) { NULL } else { tc <- .fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestNamesClassNoPublicMembers'); t <- .fastr.interop.new(tc); names(t) } NULL -##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testNamesForJavaObject# +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testNamesForForeignObject# #if (length(grep("FastR", R.Version()$version.string)) != 1) { c('field', 'method', 'staticField', 'staticMethod') } else { tc <- .fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestNamesClass'); t <- .fastr.interop.new(tc); sort(names(t)) } [1] "field" "method" "staticField" "staticMethod" -##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testNamesForJavaObject# +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testNamesForForeignObject# #if (length(grep("FastR", R.Version()$version.string)) != 1) { c('one', 'two') } else { tc <- .fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestNamesClassMap'); t <- .fastr.interop.new(tc); sort(names(t$m())) } [1] "one" "two" -##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testNamesForJavaObject# +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testNamesForForeignObject# #if (length(grep("FastR", R.Version()$version.string)) != 1) { c('staticField', 'staticMethod') } else { tc <- .fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestNamesClass'); sort(names(tc)) } [1] "staticField" "staticMethod" -##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testNew# -#if (length(grep("FastR", R.Version()$version.string)) != 1) { 'a' } else { tc <- .fastr.java.class('java.lang.Character'); t <- .fastr.interop.new(tc, .fastr.interop.toChar(97)); t } -[1] "a" - -##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testNew# -#if (length(grep("FastR", R.Version()$version.string)) != 1) { 'abc' } else { tc <- .fastr.java.class('java.lang.String'); t <- .fastr.interop.new(tc, 'abc'); t } -[1] "abc" - -##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testNew# -#if (length(grep("FastR", R.Version()$version.string)) != 1) { 'truffle.object' } else { tc <- .fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestNullClass'); t <- .fastr.interop.new(tc, NULL); class(t) } -[1] "truffle.object" - -##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testNew# -#if (length(grep("FastR", R.Version()$version.string)) != 1) { 1 } else { tc <- .fastr.java.class('java.lang.Byte'); t <- .fastr.interop.new(tc, .fastr.interop.toByte(1)); t } -[1] 1 +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testNewWithJavaClass# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { 2147483647 } else { tc <- .fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass'); to <- new(tc); to$fieldInteger } +[1] 2147483647 -##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testNew# -#if (length(grep("FastR", R.Version()$version.string)) != 1) { 1 } else { tc <- .fastr.java.class('java.lang.Integer'); t <- .fastr.interop.new(tc, 1L); t } -[1] 1 +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testNewWithJavaClass# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { 2147483647 } else { to <- new('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass'); to$fieldStaticInteger } +[1] 2147483647 -##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testNew# -#if (length(grep("FastR", R.Version()$version.string)) != 1) { 1 } else { tc <- .fastr.java.class('java.lang.Long'); t <- .fastr.interop.new(tc, .fastr.interop.toLong(1)); t } -[1] 1 +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testNewWithJavaClass# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { TRUE } else { tc <- .fastr.java.class('java.lang.Boolean'); to <- new(tc, TRUE); to } +[1] TRUE -##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testNew# -#if (length(grep("FastR", R.Version()$version.string)) != 1) { 1 } else { tc <- .fastr.java.class('java.lang.Short'); t <- .fastr.interop.new(tc, .fastr.interop.toShort(1)); t } -[1] 1 +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testNewWithJavaClass# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { TRUE } else { to <- new('java.lang.Boolean', TRUE); to } +[1] TRUE -##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testNew# -#if (length(grep("FastR", R.Version()$version.string)) != 1) { 1.1 } else { tc <- .fastr.java.class('java.lang.Double'); t <- .fastr.interop.new(tc, 1.1); t } -[1] 1.1 +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testNewWithJavaClass# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { TRUE } else { to <- new('java/lang/Boolean', TRUE); to } +[1] TRUE -##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testNew# -#if (length(grep("FastR", R.Version()$version.string)) != 1) { 1.1 } else { tc <- .fastr.java.class('java.lang.Float'); t <- .fastr.interop.new(tc, .fastr.interop.toFloat(1.1)); t } -[1] 1.1 +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testNewWithJavaClass# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { cat('Error in .fastr.interop.new(Class, ...) : ', '<<<NEWLINE>>>', ' error during Java object instantiation<<<NEWLINE>>>', sep='') } else { to <- new('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass'); new(to) } +Error in .fastr.interop.new(Class, ...) : + error during Java object instantiation -##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testNew# -#if (length(grep("FastR", R.Version()$version.string)) != 1) { TRUE } else { tc <- .fastr.java.class('java.lang.Boolean'); t <- .fastr.interop.new(tc, TRUE); t } -[1] TRUE +##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testNewWithJavaClass# +#if (length(grep("FastR", R.Version()$version.string)) != 1) { cat('Error in getClass(Class, where = topenv(parent.frame())) : ', '<<<NEWLINE>>>', ' “__bogus_class_name__†is not a defined class<<<NEWLINE>>>', sep='') } else { to <- new('__bogus_class_name__'); } +Error in getClass(Class, where = topenv(parent.frame())) : + “__bogus_class_name__†is not a defined class ##com.oracle.truffle.r.test.library.fastr.TestJavaInterop.testNonPrimitiveParameter# #if (length(grep("FastR", R.Version()$version.string)) != 1) { TRUE } else { tc <- .fastr.java.class('com.oracle.truffle.r.test.library.fastr.TestJavaInterop$TestClass'); t <- .fastr.interop.new(tc); t$equals(t) } diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/fastr/TestJavaInterop.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/fastr/TestJavaInterop.java index f9852832d2f60e5024c9e54cda373f4d034e6794..557545ba6e3be4cf0ae958db0bcbc3b97d03b1f3 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/fastr/TestJavaInterop.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/fastr/TestJavaInterop.java @@ -22,6 +22,7 @@ */ package com.oracle.truffle.r.test.library.fastr; +import com.oracle.truffle.r.nodes.builtin.fastr.FastRInterop; import com.oracle.truffle.r.runtime.RType; import org.junit.Test; @@ -33,11 +34,17 @@ import java.lang.reflect.Method; import java.util.HashMap; import java.util.Map; import org.junit.Assert; +import org.junit.Before; public class TestJavaInterop extends TestBase { private static final String TEST_CLASS = TestClass.class.getName(); + @Before + public void testInit() { + FastRInterop.testingMode(); + } + @Test public void testToByte() { assertEvalFastR("v <- .fastr.interop.toByte(1L); v;", "1"); @@ -191,8 +198,9 @@ public class TestJavaInterop extends TestBase { } @Test - public void testNew() { + public void testInteroptNew() { assertEvalFastR("tc <- .fastr.java.class('" + Boolean.class.getName() + "'); t <- .fastr.interop.new(tc, TRUE); t", "TRUE"); + assertEvalFastR("tc <- .fastr.java.class('java/lang/Boolean'); t <- new(tc, TRUE); t", "TRUE"); assertEvalFastR("tc <- .fastr.java.class('" + Byte.class.getName() + "'); t <- .fastr.interop.new(tc, .fastr.interop.toByte(1)); t", "1"); assertEvalFastR("tc <- .fastr.java.class('" + Character.class.getName() + "'); t <- .fastr.interop.new(tc, .fastr.interop.toChar(97)); t", "'a'"); assertEvalFastR("tc <- .fastr.java.class('" + Double.class.getName() + "'); t <- .fastr.interop.new(tc, 1.1); t", "1.1"); @@ -204,6 +212,20 @@ public class TestJavaInterop extends TestBase { assertEvalFastR("tc <- .fastr.java.class('" + TestNullClass.class.getName() + "'); t <- .fastr.interop.new(tc, NULL); class(t)", "'" + RType.TruffleObject.getName() + "'"); } + @Test + public void testNewWithJavaClass() { + assertEvalFastR("tc <- .fastr.java.class('" + Boolean.class.getName() + "'); to <- new(tc, TRUE); to", "TRUE"); + assertEvalFastR("tc <- .fastr.java.class('" + TEST_CLASS + "'); to <- new(tc); to$fieldInteger", getRValue(Integer.MAX_VALUE)); + + assertEvalFastR("to <- new('" + Boolean.class.getName() + "', TRUE); to", "TRUE"); + assertEvalFastR("to <- new('java/lang/Boolean', TRUE); to", "TRUE"); + assertEvalFastR("to <- new('" + TEST_CLASS + "'); to$fieldStaticInteger", getRValue(Integer.MAX_VALUE)); + + assertEvalFastR("to <- new('" + TEST_CLASS + "'); new(to)", "cat('Error in .fastr.interop.new(Class, ...) : ', '\n', ' error during Java object instantiation\n', sep='')"); + + assertEvalFastR("to <- new('__bogus_class_name__');", "cat('Error in getClass(Class, where = topenv(parent.frame())) : ', '\n', ' “__bogus_class_name__†is not a defined class\n', sep='')"); + } + @Test public void testCombineInteropTypes() { assertEvalFastR("class(c(.fastr.interop.toByte(123)))", "'interopt.byte'"); @@ -329,7 +351,7 @@ public class TestJavaInterop extends TestBase { } @Test - public void testNamesForJavaObject() { + public void testNamesForForeignObject() { assertEvalFastR("tc <- .fastr.java.class('" + TestNamesClassNoMembers.class.getName() + "'); t <- .fastr.interop.new(tc); names(t)", "NULL"); assertEvalFastR("tc <- .fastr.java.class('" + TestNamesClassNoPublicMembers.class.getName() + "'); t <- .fastr.interop.new(tc); names(t)", "NULL"); assertEvalFastR("tc <- .fastr.java.class('" + TestNamesClass.class.getName() + "'); sort(names(tc))", "c('staticField', 'staticMethod')"); @@ -340,6 +362,63 @@ public class TestJavaInterop extends TestBase { assertEvalFastR("tc <- .fastr.java.class('" + TestNamesClassMap.class.getName() + "'); t <- .fastr.interop.new(tc); sort(names(t$m()))", "c('one', 'two')"); } + @Test + public void testIsXXXForForeignObject() { + // missing: is.element, is.empty.model, is.leaf, is.loaded, is.na.data.frame, + // is.na.numeric_version, is.na.POSIXlt + + assertPassingForeighObjectToFunction("is.array", "FALSE"); + assertPassingForeighObjectToFunction("is.atomic", "FALSE"); + assertPassingForeighObjectToFunction("is.call", "FALSE"); + assertPassingForeighObjectToFunction("is.character", "FALSE"); + assertPassingForeighObjectToFunction("is.complex", "FALSE"); + assertPassingForeighObjectToFunction("is.data.frame", "FALSE"); + assertPassingForeighObjectToFunction("is.double", "FALSE"); + assertPassingForeighObjectToFunction("is.environment", "FALSE"); + assertPassingForeighObjectToFunction("is.expression", "FALSE"); + assertPassingForeighObjectToFunction("is.factor", "FALSE"); + assertPassingForeighObjectToFunction("is.function", "FALSE"); + assertPassingForeighObjectToFunction("is.integer", "FALSE"); + assertPassingForeighObjectToFunction("is.language", "FALSE"); + assertPassingForeighObjectToFunction("is.logical", "FALSE"); + assertPassingForeighObjectToFunction("is.matrix", "FALSE"); + assertPassingForeighObjectToFunction("is.mts", "FALSE"); + assertPassingForeighObjectToFunction("is.na", "FALSE"); + assertPassingForeighObjectToFunction("is.name", "FALSE"); + assertPassingForeighObjectToFunction("is.null", "FALSE"); + assertPassingForeighObjectToFunction("is.numeric", "FALSE"); + assertPassingForeighObjectToFunction("is.numeric.Date", "FALSE"); + assertPassingForeighObjectToFunction("is.numeric.difftime", "FALSE"); + assertPassingForeighObjectToFunction("is.numeric.POSIXt", "FALSE"); + assertPassingForeighObjectToFunction("is.numeric_version", "FALSE"); + assertPassingForeighObjectToFunction("is.object", "FALSE"); + assertPassingForeighObjectToFunction("is.ordered", "FALSE"); + assertPassingForeighObjectToFunction("is.package_version", "FALSE"); + assertPassingForeighObjectToFunction("is.pairlist", "FALSE"); + assertPassingForeighObjectToFunction("is.primitive", "FALSE"); + assertPassingForeighObjectToFunction("is.qr", "FALSE"); + assertPassingForeighObjectToFunction("is.raster", "FALSE"); + assertPassingForeighObjectToFunction("is.raw", "FALSE"); + assertPassingForeighObjectToFunction("is.recursive", "FALSE"); + assertPassingForeighObjectToFunction("is.relistable", "FALSE"); + assertPassingForeighObjectToFunction("is.stepfun", "FALSE"); + assertPassingForeighObjectToFunction("is.symbol", "FALSE"); + assertPassingForeighObjectToFunction("is.table", "FALSE"); + assertPassingForeighObjectToFunction("is.ts", "FALSE"); + assertPassingForeighObjectToFunction("is.tskernel", "FALSE"); + assertPassingForeighObjectToFunction("is.unsorted", "FALSE"); + assertPassingForeighObjectToFunction("is.vector", "FALSE"); + + assertPassingForeighObjectToFunction("is.nan", "cat('Error in is.nan(to) : ', '\n', ' default method not implemented for type \\'external object\\'\n', sep='')"); + assertPassingForeighObjectToFunction("is.finite", "cat('Error in is.finite(to) : ', '\n', ' default method not implemented for type \\'external object\\'\n', sep='')"); + assertPassingForeighObjectToFunction("is.infinite", "cat('Error in is.infinite(to) : ', '\n', ' default method not implemented for type \\'external object\\'\n', sep='')"); + + } + + private void assertPassingForeighObjectToFunction(String function, String expectedOutput) { + assertEvalFastR("to <- .fastr.interop.new(.fastr.java.class('" + TEST_CLASS + "')); " + function + "(to)", expectedOutput); + } + @Test public void testAttributes() { assertEvalFastR("to <- .fastr.interop.new(.fastr.java.class('" + TEST_CLASS + "')); attributes(to)", "NULL");