Open ggrossetie opened 5 years ago
We could maybe define Proxy
to customize Java interoperability:
https://www.graalvm.org/docs/graalvm-as-a-platform/embed/#computed-arrays-using-polyglot-proxies https://www.graalvm.org/sdk/javadoc/org/graalvm/polyglot/proxy/Proxy.html
Using Java extension is not an easy task because we need to register dynamically a Java function an call it from JavaScript with instance (instantiated in the JavaScript engine).
Let's take an example:
In the example above, we need to call the
process
method from JavaScript with aStructuralNode
instance, aReader
instance and aMap
of attributes. The JavaScript runtime has aparent
and areader
object in memory but these objects are not available in Java. The Java code is also calling thecreateBlock
method with aStructuralNode
(Java), so again we need to resolve this object in the JavaScript runtime.Technically using a shared memory with "pointer" in the JavaScript runtime is working but I don't know if it's the best approach here.