Classpath hell with Truffle development

Christian Humer christian.humer at gmail.com
Wed Nov 21 15:40:14 UTC 2018


Hi Timothy,

We will update our doc regarding this shortly. Sorry for the inconvenience
this has caused.
We normally recommend, to fork the SL project[1] where this is already
taken care of [2].

We do not recommend to use -XX:-UseJVMCIClassLoader with GraalVM in
production.
It is ok to use it for testing, e.g. if you want to touch the internals of
your language.
For production usage, we recommend to either make your language an
installable GraalVM component[3]
Or, to use -Dtruffle.class.path.append=mylanguage.jar to put your language
on the language classpath [4].

We isolate the language classpath in order to avoid any conflicts with
dependencies of the host application. We basically made it harder to
integrate languages, but at the same time we made it easier for embedders/
host applications to use the language. Also we want to ensure that host
applications don't depend internal APIs of the language. (something that
will be taken care of by Jigsaw on JDK >= 11).


[1] https://github.com/graalvm/simplelanguage/
[2]
https://github.com/graalvm/simplelanguage/blob/master/language/pom.xml#L29
[3] https://github.com/graalvm/simplelanguage/tree/master/component
[4] https://github.com/graalvm/simplelanguage/blob/master/sl#L73


- Christian Humer




On Wed, Nov 21, 2018 at 7:07 AM Timothy Baldridge <tbaldridge at gmail.com>
wrote:

> Welp, my google-fu finally kicked in and I found this:
> https://github.com/oracle/graal/issues/311, adding
> -XX:-UseJVMCIClassLoader
> to the JVM invocation fixed my issues.
>
> On Tue, Nov 20, 2018 at 9:51 PM Timothy Baldridge <tbaldridge at gmail.com>
> wrote:
>
> > in my continued adventures of writing a Truffle language, I'm hitting an
> > annoying problem. It seems that in order to compile my language I need to
> > load TruffleLanguage (from truffle-api) on my classpath. However, once I
> > do, graalvm loads the class again. I then get a "Cannot cast X to
> > TruffleLanguage" exception, if I go in with a debugger I see that my
> > language does inherit from TruffleLanguage, just not the TruffleLanguage
> > that Graal is expecting. If I run the jvm with -verbose:class I see the
> > following lines:
> >
> > [Loaded com.oracle.truffle.api.TruffleLanguage from
> >
> file:/home/tbaldrid/graalvm-ce-1.0.0-rc9/jre/lib/jvmci/../truffle/truffle-api.jar]
> > [Loaded com.oracle.truffle.api.TruffleLanguage from
> > file:/home/tbaldrid/graalvm-ce-1.0.0-rc9/jre/lib/truffle/truffle-api.jar]
> >
> > Any ideas what's causing this? If I remove truffle-api from my project
> > dependencies then the project won't load at all due to missing classes.
> If
> > I add truffle-api, then I get duplicates.
> >
> > I'm doing this with a maven project, Intelij and I'm using graal-vm as my
> > JDK.
> >
> > Timothy
> >
>
>
> --
> “One of the main causes of the fall of the Roman Empire was that–lacking
> zero–they had no way to indicate successful termination of their C
> programs.”
> (Robert Firth)
>


More information about the graal-dev mailing list