graalvm / graal-js-jdk11-maven-demo

An example project how to run Graal/JavaScript on JDK 11 with Graal as optimizing JIT compiler for best performance.
Universal Permissive License v1.0
177 stars 63 forks source link

Getting PolyglotMap Object type Returned When Using GraalVM in Java Instead My Own Proxy Object Type #44

Open shaharzillber opened 8 months ago

shaharzillber commented 8 months ago

I'm currently working with GraalVM in Java and encountering an issue with the object type returned by a function. Here's the code snippet:

import com.oracle.truffle.js.scriptengine.GraalJSScriptEngine;
import org.graalvm.polyglot.HostAccess;
import org.graalvm.polyglot.Value;

myRunFunction(myOwnObject input) {
    myOwnProxyObject finalInput = new myOwnProxyObject(input);
    Object result;
    try {
        result = Engine.invokeFunction(myJSCode, finalInput, context, logger, data, anotherData);
    } catch(Exception e){
        //do something
    }

//do other
}

The problem is that the result object is of type polygloMtap instead of the expected myOwnProxyObject. Can anyone help me understand why this is happening and how I can ensure the function returns an object of type myOwnProxyObject? Any help would be greatly appreciated.

Here's what I've attempted so far: Initially, I was working with the object type myOwnObject. However, after conducting some research, I realized that this approach might not be the most efficient. Despite this, I still received an object of type myOwnObject. This led me to suspect that there might be an issue with the implementation of myOwnProxyObject. However, I'm currently unsure of what the specific problem could be. I'm looking for guidance on what could potentially be wrong with my myOwnProxyObject implementation.