简体   繁体   中英

Combine custom DSL and provided languages with GraalVM / Truffle framework

I am working with the Truffle framework on GraalVM to prototype implementation of a DSL. Currently my code application compiles the DSL directly to JVM bytecode using ASM, it then dynamically loads the generated class. In order to make it more maintainable and easier to extend I'd like to implement my language on Truffle instead.

I also currently use Python and JS via GraalVM / Truffle from the provided components. How can I get my language to work alongside the supplied ones? According to the documentation I need to set "-Dgraalvm.locatorDisabled=true" for my language implementation to be found - this works. Without it I cannot use it. However, when I enable that then I am unable to use JS and Python. The documentation also says "To still use the builtin languages add them to the module-path by pointing the module-path to all needed language homes (eg $GRAALVM/languages/js).".

This is not working for me. I get an error: java.lang.module.ResolutionException: Module org.graalvm.js does not read a module that exports com.oracle.truffle.api

How can I fix that. Or alternatively, is there a better way possible to use my language along with the provided ones? It seems to me logically that there should be a programatic way to 'register' my language with the context when I build it by passing it the language implementation class.

I cannot deploy my language as a component because it is very specific to the host application and can only work in-process with my application. Building it as a component would complicate the build and deployment process and require including a massive number of additional JARS and would expose it to the wider system where it is irrelevant.

For context, the DSL in question is a query language (think SQL) that enables users to define queries for the system that efficiently interact with the in-memory cache.

Thanks, Troy

Sanity check: Are you using the truffle-api.jar from maven like suggested in the docs ?

The Language API JAR on Maven Central exports all API packages in its module-info. Apply the --upgrade-module-path option together with -Dgraalvm.locatorDisabled=true and this JAR to export Language API packages:

-Dgraalvm.locatorDisabled=true --module-path=<yourModulePath>:${truffle.dir} --upgrade-module-path=${truffle.dir}/truffle-api.ja

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM