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

Fails to compile project on Windows with Java 11 (Unknown compiler options: -release, 11) #6829

Closed
mikhail-buhayenka opened this issue Oct 9, 2024 · 7 comments · Fixed by scalacenter/bloop#2462
Milestone

Comments

@mikhail-buhayenka
Copy link

Hi

When I try to compile my project with Java 11 (and Scala 2.11.12) I get the following error:
WARNING: Unknown compiler options: -release, 11 Oct 09, 2024 11:22:47 AM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint handleNotification WARNING: Notification threw an exception: { "jsonrpc": "2.0", "method": "build/logMessage", "params": { "type": 1, "message": "bad option: \u0027-release\u0027" } } java.nio.file.InvalidPathException: Illegal char <:> at index 12: r_bad option: '-releas..._11-22-47-499.md at java.base/sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182) at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)

My Metals Java config:
image

But it works just fine when I configure it to use Java 21 for some reason (Java 17 gives me the same error). I have to use Java 11 for my project so any help would be appreciated
Build config is generated from maven pom.xml, there are no compiler args set there in pom
I have code autocompletion active but whenever I try to run my code it runs unmodified code (seems like it fails to compile new jar file to .metals/.tmp/... directory but not sure

Operating system:
Windows 11

Java version:
11.0.24

Editor/extension:
Visual Studio Code v1.94.1

Metals version:
1.3.5

Workspace information:

  • Scala versions: 2.11.12
  • Build tools: 0. mvn
  • Build servers:
    0. Bloop v1.6.0
  • All build tools in workspace: Bloop; Maven
@tgodzik
Copy link
Contributor

tgodzik commented Oct 9, 2024

Thanks for reporting! What is the full exception that you are getting? Also, does it work if you just change the metals java home to JDK 21? That should only be responsible for JDK Metals is using.

@mikhail-buhayenka
Copy link
Author

Still same exception when setting Java 21 as Metals java home like this:
image

Full exception:
WARNING: Notification threw an exception: { "jsonrpc": "2.0", "method": "build/logMessage", "params": { "type": 1, "message": "bad option: \u0027-release\u0027" } } java.nio.file.InvalidPathException: Illegal char <:> at index 12: r_bad option: '-releas..._12-08-36-977.md at java.base/sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:204) at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:175) at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77) at java.base/sun.nio.fs.WindowsPath.parse(WindowsPath.java:92) at java.base/sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:231) at java.base/java.nio.file.Path.resolve(Path.java:516) at scala.meta.internal.metals.StdReporter.reportPath(ReportContext.scala:165) at scala.meta.internal.metals.StdReporter.create(ReportContext.scala:131) at scala.meta.internal.builds.BspErrorHandler.createReport(BSPErrorHandler.scala:38) at scala.meta.internal.builds.BspErrorHandler.onError(BSPErrorHandler.scala:22) at scala.meta.internal.metals.clients.language.ForwardingMetalsBuildClient.onBuildLogMessage(ForwardingMetalsBuildClient.scala:136) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) at java.base/java.lang.reflect.Method.invoke(Method.java:580) at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$recursiveFindRpcMethods$0(GenericEndpoint.java:65) at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.notify(GenericEndpoint.java:160) at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleNotification(RemoteEndpoint.java:231) at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:198) at scala.meta.internal.metals.RequestMonitorImpl$$anon$1.consume(ServerLivenessMonitor.scala:41) at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:185) at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:97) at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:114) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) at java.base/java.lang.Thread.run(Thread.java:1583)

@tgodzik
Copy link
Contributor

tgodzik commented Oct 9, 2024

Ach, that looks like an issue with our reporting. I can fix that, but I don't think that is related to any serious issues. For the -release option we might be adding that automatically, I need to see it in Bloop.

@mikhail-buhayenka
Copy link
Author

Thanks! Main issue that I have is when I use command 'Metals: run main class or test in the current file' it runs some older version of this file so any modifications that I've done to the file are not synced and it looks like it runs previously compiled one, example:
image

@mikhail-buhayenka
Copy link
Author

It turns out code autocompletion doesn't really work either for me when I choose Java 11, but with Java 21 it works perfect (with Java 11 it gives me some completion suggestions still but not everywhere so I think that might be some cached suggestions from previous Java 21 compilation builds)

@mikhail-buhayenka
Copy link
Author

@tgodzik thanks you so much for very quick response and the fix! do you have any idea when the next plugin version that includes it comes out?

@tgodzik
Copy link
Contributor

tgodzik commented Oct 14, 2024

I want to wait for another PR in progress and will most likely release at that point. You could try to use the latest Bloop with the latest Metals snapshot already by changing:
"metals.serverVersion" : "1.3.5+171-b77fedf0-SNAPSHOT"
"metals.bloopVersion" : "2.0.3-14-83e26285-SNAPSHOT"

That should contain the fix.

@tgodzik tgodzik added this to the Metals v1.4.0 milestone Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants