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

metac is fragile on JDK 11 (URLClassLoader/app class loader) #1985

Open
dwijnand opened this issue Feb 12, 2020 · 0 comments
Open

metac is fragile on JDK 11 (URLClassLoader/app class loader) #1985

dwijnand opened this issue Feb 12, 2020 · 0 comments

Comments

@dwijnand
Copy link
Contributor

dwijnand commented Feb 12, 2020

One of the changes in JDK 11 is that the application classloader isn't a URLClassLoader, see https://blog.codefx.org/java/java-11-migration-guide/#Casting-To-URL-Class-Loader.

While looking at https://scalameta.org/docs/semanticdb/guide.html#installation, I switch the instructions to use Coursier's sexy, new cs launchers, and found it to blow up because I was using JDK 11:

$ cs launch org.scalameta:metac_2.13.1:4.3.0 -- -cp $(cs fetch -p org.scala-lang:scala-library:2.13.1) Test.scala
Exception in thread "main" java.lang.RuntimeException: unsupported classloader: jdk.internal.loader.ClassLoaders$AppClassLoader@6ff3c5b5
	at scala.sys.package$.error(package.scala:27)
	at scala.meta.internal.metac.Main.process(Main.scala:23)
	at scala.meta.cli.Metac$.process(Metac.scala:36)
	at scala.meta.cli.Metac$.process(Metac.scala:27)
	at scala.meta.cli.Metac$.main(Metac.scala:10)
	at scala.meta.cli.Metac.main(Metac.scala)

I opened the issue in Coursier (coursier/coursier#1572) and found out it's also possible to blow it up with the old launcher, by making it spawn a new JVM:

$ coursier launch --fork org.scalameta:metac_2.13.1:4.3.0 -- -cp $(coursier fetch -p org.scala-lang:scala-library:2.13.1) Test.scala
Exception in thread "main" java.lang.RuntimeException: unsupported classloader: jdk.internal.loader.ClassLoaders$AppClassLoader@6ff3c5b5
	at scala.sys.package$.error(package.scala:27)
	at scala.meta.internal.metac.Main.process(Main.scala:23)
	at scala.meta.cli.Metac$.process(Metac.scala:36)
	at scala.meta.cli.Metac$.process(Metac.scala:27)
	at scala.meta.cli.Metac$.main(Metac.scala:10)
	at scala.meta.cli.Metac.main(Metac.scala)

(There's also a few more references to URLClassLoader in the repo: https://github.com/scalameta/scalameta/search?q=URLClassLoader.)

@dwijnand dwijnand changed the title metac is fragile on JDK 11 (URLClassLoader/application class loader) metac is fragile on JDK 11 (URLClassLoader/app class loader) Feb 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant