graal icon indicating copy to clipboard operation
graal copied to clipboard

Unable to find language by ID despite registration, adding classpath, and jar

Open msp-gh opened this issue 10 months ago • 6 comments

Output of java -Xinternalversion:

Java HotSpot(TM) 64-Bit Server VM (22.0.1+8-jvmci-b01) for bsd-aarch64 JRE (22.0.1+8-jvmci-b01), built on 2024-03-14T12:26:11Z by "graal1" with clang Apple LLVM 14.0.3 (clang-1403.0.22.14.1)

Was obtained from/using: sdk install java 22.0.1-graal.

Issue: I'm using Truffle to build my own language and I've annotated the TruffleLanguage subtype using the Registration annotation. I've also added the jar using -Dtruffle.class.path.append= option. However, Truffle still complains that it can't find my language by the ID.

Here's the build file:

lazy val root = project
  .in(file("."))
  .settings(
    name := "truffle-lang",
    scalaVersion := "3.4.0",
    run / fork := true,
    javaOptions += "-Dtruffle.class.path.append=/Users/username/Repos/truffle-lang/target/scala-3.4.0/truffle_lang_3-0.1.0-SNAPSHOT.jar",

    // Dependencies
    libraryDependencies += "org.graalvm.truffle" % "truffle-api" % "24.0.1",
    libraryDependencies += "org.graalvm.truffle" % "truffle-dsl-processor" % "24.0.1",
  )

Error:

Exception in thread "main" java.lang.IllegalArgumentException: A language with id '<lang ID>' is not installed. Installed languages are: [].

Here's how my TruffleLanguage sub type looks like:

// ID, name, and version are redacted. They're filled in correctly.
@TruffleLanguage.Registration(id = "<lang ID>", name = "<lang name>", version = "<version>")
final class TruffleLanguage extends TruffleLanguage[TruffleContext] {
  // ...
}

I'd be glad if someone could help me out.

msp-gh avatar Apr 23 '24 14:04 msp-gh

Hello @msp-gh, we are working on this. We will get back to you as soon as we can.

ZynoZin avatar Apr 25 '24 14:04 ZynoZin

Hi @ZynoZin. Do you have any update for me?

msp-gh avatar Apr 29 '24 15:04 msp-gh

Hi @msp-gh, can you please share a reproducer with steps, as this is complicated to reproduce without one

hamzaGhaissi avatar Apr 30 '24 11:04 hamzaGhaissi

I've attached the build.sbt file and the TruffleLanguage class in the above description. Just the class and the build file is all you need to reproduce the issue. Are you able to use the Registration annotation and register the language in Scala?

msp-gh avatar Apr 30 '24 14:04 msp-gh

Hi @msp-gh we apologize for the late response. You are using JDK22, so all languages should be proper modules and put on the JVM module path. This blog post should be relevant to your use case.

I think @chumer might have more info to help you about this.

ZynoZin avatar May 06 '24 15:05 ZynoZin

@ZynoZin I have an update for you. If TruffleLanguage class (that's mentioned in the above description) is changed to Java file (with the exact same setup and no other changes), Truffle is able to see my language. If I change it to Scala, Truffle has problems finding it. The registration annotation is present in the bytecode generated by the Scala compiler. Any idea what's happening here? I think the problem is related to the annotation processing and the subsequent finding by Truffle.

cc @chumer

msp-gh avatar May 15 '24 14:05 msp-gh