Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
msp-gh opened this issue Apr 23, 2024 · 6 comments
Open
Assignees
Labels

Comments

@msp-gh
Copy link

msp-gh commented Apr 23, 2024

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.

@ZynoZin
Copy link
Member

ZynoZin commented Apr 25, 2024

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

@msp-gh
Copy link
Author

msp-gh commented Apr 29, 2024

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

@hamzaGhaissi
Copy link
Member

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

@msp-gh
Copy link
Author

msp-gh commented Apr 30, 2024

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?

@ZynoZin
Copy link
Member

ZynoZin commented May 6, 2024

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.

@msp-gh
Copy link
Author

msp-gh commented May 15, 2024

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants