Skip to content

Commit e4f527a

Browse files
committed
hope this solves the graal js issues with java interop #1558
more details at the issue comments
1 parent 66aeaa3 commit e4f527a

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

karate-core/src/main/java/com/intuit/karate/core/ScenarioEngine.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1091,7 +1091,7 @@ private Object recurseAndAttach(Object o, Set<Object> seen) {
10911091
return attach(value);
10921092
}
10931093
} catch (Exception e) {
1094-
logger.trace("failed to re-attach graal value (will re-try): {}", e.getMessage());
1094+
logger.trace("[attach] failed to re-attach graal value (will re-try): {}", e.getMessage());
10951095
try {
10961096
return Value.asValue(value.asHostObject());
10971097
} catch (Exception inner) {
@@ -1142,12 +1142,12 @@ private Object recurseAndAttachAndDeepClone(Object o, Set<Object> seen) {
11421142
// should never happen if the detach was done properly
11431143
Value value = (Value) o;
11441144
try {
1145-
if (value.canExecute()) {
1145+
if (value.canExecute() || value.isMetaObject()) {
11461146
return attach(value);
11471147
}
11481148
o = JsValue.toJava(value);
11491149
} catch (Exception e) {
1150-
logger.trace("failed to re-attach graal value (will re-try): {}", e.getMessage());
1150+
logger.trace("[attach deep] failed to re-attach graal value (will re-try): {}", e.getMessage());
11511151
try {
11521152
return Value.asValue(value.asHostObject());
11531153
} catch (Exception inner) {

karate-core/src/test/java/com/intuit/karate/core/parajava/ParallelJavaTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
public class ParallelJavaTest {
1010

11-
// @Test
11+
@Test
1212
public void testParallel() {
1313
Results results = Runner.path("classpath:com/intuit/karate/core/parajava/parallel-java.feature")
1414
.configDir("classpath:com/intuit/karate/core/parajava")

karate-core/src/test/java/com/intuit/karate/graal/JsEngineTest.java

+7
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,13 @@ void testValueAndHostObject() {
192192
Value v = Value.asValue(sp);
193193
assertTrue(v.isHostObject());
194194
}
195+
196+
@Test
197+
void testJavaType() {
198+
Value v = je.evalForValue("Java.type('com.intuit.karate.graal.SimplePojo')");
199+
assertTrue(v.isMetaObject());
200+
assertTrue(v.isHostObject());
201+
}
195202

196203
@Test
197204
void testEvalWithinFunction() {

0 commit comments

Comments
 (0)