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

Add options for import java.compiler module #1395

Merged
merged 3 commits into from
May 20, 2023

Conversation

VankaTaganai
Copy link
Contributor

This changes related to Java Hover for Metals. It's required to export java.compiler module manually for Java version greater than 17. I've handled version of Java like it's made in Metals.

@VankaTaganai VankaTaganai force-pushed the java-compiler-add-opens-options branch from 8941b7e to bc36900 Compare May 17, 2023 19:01
Copy link
Member

@dos65 dos65 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works well!

I just submitted a minor fix onto your branch - I realized that we actually have an actual javaHome and there is no need to extract it back from env.

serverOptions - pass javaHome explicitly
@dos65 dos65 merged commit cf748dd into scalameta:main May 20, 2023
10 checks passed
@dos65
Copy link
Member

dos65 commented May 20, 2023

@ckipp01 @ayoub-benali - Hey! Could you say if you will be able to port changeset from this PR for nvim and sublime?
They are needed for better java support in case if jvm is greater or eq of 17.

@ckipp01
Copy link
Member

ckipp01 commented May 20, 2023

@ckipp01 @ayoub-benali - Hey! Could you say if you will be able to port changeset from this PR for nvim and sublime? They are needed for better java support in case if jvm is greater or eq of 17.

Thanks for the ping @dos65! I haven't been following the work on the Java hover pr, but how come this is actually necessary? I don't mean why are the extra flags necessary, but how come they need to be used to start Metals? I was under the assumption that when Metals started the java compiler or whatever was being used it could pass in those flags so the client doesn't need to worry about them. Is that at all possible, or is absolutely necessary that Metals is started with those flags?

To answer your original question, I think this should be portable, I just need to rewrite it in lua for nvim-metals.

@ayoub-benali
Copy link

Hey @dos65, from my understanding a set of flags are passed to the client if java_home is 17 or above. It shouldn't be a problem to do that for sublime

@dos65
Copy link
Member

dos65 commented May 22, 2023

@ckipp01

Thanks for the ping @dos65! I haven't been following the work on the Java hover pr, but how come this is actually necessary? I don't mean why are the extra flags necessary, but how come they need to be used to start Metals? I was under the assumption that when Metals started the java compiler or whatever was being used it could pass in those flags so the client doesn't need to worry about them. Is that at all possible, or is absolutely necessary that Metals is started with those flags?

Yep, unfortunately it's necessary. It doesn't affect Metals startup but in runtime for jdk17 there will be errors in case of JavaPC execution. We can't pass there flags as JavaPC is not a separate process, Metals runs it in the same way as ScalaPC.
I was googling a bit but haven't found any reliable workaround.

I theory there is an option to make some kind metals-launcher that can detect jdk version and run actual process with or without flags and doing an proxy for stdin/stdout. However, this solution has more drawbacks rather than making such changes in clients.

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

Successfully merging this pull request may close these issues.

None yet

4 participants