-
Notifications
You must be signed in to change notification settings - Fork 1
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
Access Javac API from a standalone javac jar instead of the default JDK runtime #924
base: dom-with-javac
Are you sure you want to change the base?
Access Javac API from a standalone javac jar instead of the default JDK runtime #924
Conversation
Does the launch configuration or the java command still set the |
I removed the Line 565 in d8b4f12
|
Found this on ClearlyDefined with a score that makes it usable, Update: It is Approved ✔️ |
In recent commits, I addressed two issues:
In the latest commit, the DOM resolver already works with the embedded Javac. But for the build support, it still has some problems because the apt plugin is not loaded well. Here are some potential issues to look further.
|
I attempted to convert the
I guess this dependency issue is why the javac plugin is set up as a fragment of jdt.core, allowing it to share the same classloader. |
@@ -5,7 +5,10 @@ Bundle-SymbolicName: org.eclipse.jdt.core.javac;singleton:=true | |||
Bundle-Version: 1.0.0.qualifier | |||
Fragment-Host: org.eclipse.jdt.core | |||
Automatic-Module-Name: org.eclipse.jdt.core.javac | |||
Require-Capability: osgi.ee; filter:="(&(osgi.ee=JavaSE)(version=23))" | |||
Require-Capability: osgi.ee; filter:="(&(osgi.ee=JavaSE)(version=17))" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See https://ci.eclipse.org/ls/job/jdt-core-incubator/job/PR-924/3/console , this breaks current compilation since some Java 21 features are already adopted in the code. Would 21 be fine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it breaks Java 21 usage (e.g. some utility of String and pattern matching). We need to rewrite them with Java 17 compatible way. The purpose here is to make the minimum JDK requirement same as other JDT plugins.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, at this stage, we should minimize the changes in the code and stick to Java 21 to facilitate progress. When we've adopted nb-javac, then we'll be more easily able to move code back to Java 17. Moreover, m2e already requires Java 21, so JDT-LS already requires Java 21, so trying to go below that won't produce any benefit for JDT-LS nor vscode-java.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see redhat.java extension still requires a minimum Java 17 because it stays at m2e@2.6.0. Good to know we're going to upgrade to Java 21.
- This also fixes the quickfix as a result eg. ```java Function<Integer, Integer> func = x -> { System.out.println(x); }; ``` becomes ```java Function<Integer, Integer> func = x -> { System.out.println(x); return x; }; ``` Signed-off-by: David Thompson <davthomp@redhat.com>
Different versions of Java allow different modifiers on interface methods, so ECJ generates slightly different problem ids for each of these cases. Use the compiler settings to determine which to use. This affects the logic of the quick fixes, so it should fix some jdt-ls test cases. Signed-off-by: David Thompson <davthomp@redhat.com>
Signed-off-by: Rob Stryker <stryker@redhat.com>
hashcode/equals
Signed-off-by: Rob Stryker <stryker@redhat.com>
Signed-off-by: Rob Stryker <stryker@redhat.com>
Signed-off-by: Rob Stryker <stryker@redhat.com>
Signed-off-by: Rob Stryker <stryker@redhat.com> Fix regression Signed-off-by: Rob Stryker <stryker@redhat.com> Fix regressions Signed-off-by: Rob Stryker <stryker@redhat.com>
Signed-off-by: Rob Stryker <stryker@redhat.com>
Signed-off-by: Rob Stryker <stryker@redhat.com>
Signed-off-by: Rob Stryker <stryker@redhat.com>
…compilation unit Signed-off-by: Rob Stryker <stryker@redhat.com>
Signed-off-by: Rob Stryker <stryker@redhat.com>
Signed-off-by: Rob Stryker <stryker@redhat.com>
- Do not reuse the context when compiling to multiple output directories - Implement Alex's idea of a separate file of javac-specific error codes Signed-off-by: David Thompson <davthomp@redhat.com>
work-in-progress: - prefix filtering - see if I can get the binding key bugs resolved Fixes eclipse-jdt#938 Signed-off-by: David Thompson <davthomp@redhat.com>
In order to accomplish this, I have changed the logic for adjusting the offset used for the node search. This causes some regressions: - A few cases where the test expects the AST not to be recovered but javac does recover it (eg. org.eclipse.jdt.core.tests.model.CompletionTests_1_5.test0197) - @| in Javadoc is not handled. Before it got no completion due to not finding the correct node, but now it gets default completion, which causes some regressions. I'll fix these when dealing with @| properly - The test cases sometimes expect the current class to be suggested in new | completion even when the type doesn't match, but sometimes they don't. I'll need to investigate further Signed-off-by: David Thompson <davthomp@redhat.com>
When resolving, we do only need the symbols/bindings of depedencies. Minimize the amount of option to skip eg parsing Javadoc for transitive files that are only relevant as part of binding resolution.
- Both block and inline tags - Take into account which ones are applicable to the declaration being Javadocumented Fixes eclipse-jdt#948 Signed-off-by: David Thompson <davthomp@redhat.com>
as it's reused on the whole lifecyle of JDT.
* Also do not share the Platform filemanager with build (a bit more isolation) * a few other optimization to save CPU on irrelevant operations
Because resolving from .class deps is much faster than resolving from .java deps
It's most likely useless to get linting when none of those are requested.
86f68f9
to
ea7bd25
Compare
Following the suggestions in eclipse-equinox/equinox#697, I have removed the However, one remaining issue with the embedded javac is that it does not include the If we choose to support the embedded javac library, we will need to explore alternative approaches to implement snippet support. |
IMO it should be reported to netbeans and hear from them whether they are willing to include these packages before making a decision. |
|
Eclipse JDT provides semantic search/reference/bindings/completion... inside Javadoc. In JDT DOM, Javadoc are pretty standard elements and the javadoc needs to be parsed and its symbols resolved too in order to enable all the expected features. The jdk.javadoc package provides some APIs to retrieve the necessary info from JDK and turn it into JDT model. |
I think you mentioned here is the javadoc comments in source code. The com.sun.source.doctree package in javac (part of the On the other hand, jdk.javadoc module is primarily used by |
I had missed on message, sorry. So it looks like the Javadoc snippet feature requires the jdk.compiler module. In practice, I don't think there is a way to provide that without using JDK stuff as AFAIK there is really not any other existing implementation. |
it's this PR #812 that uses some classes from jdk.javadoc. I see you use it to parse markdown/html. I believe there is alternative open-source markdown library we can use for this. |
I'm wondering whether it wouldn't be simpler to just ship 1 fragment for each compatible version of Java that to use nb-javac. The only drawback would be that when a newer version of Java appears, we'd have to create a new fragment for it and ensure some compatibility (this can be configured in a build to ensure we use the right Java version); but even that drawback can IMO lead to higher quality on the long run. |
what benefits can we get from packaging multiple fragments for different java versions? could you explain it more? |
We could get Javac stuff in JDT-LS running on any current or older version we decide to target. |
this can be a way to solve the compatibility issue of the javac plugins such as lombok. |
For snippet javadoc issue in the PR #812, this is just a formatting thing. I'm not too worried about its support when we switch to nb-javac. We can implement a simple algorithm to handle it ourselves or reuse the solution of ECJ such as eclipse-jdt#60. |
7f5c20a
to
87832d6
Compare
For the license, here is the hint from EDP handbook: https://www.eclipse.org/projects/handbook/#ip-sbom . We should probably add an |
aa3b08f
to
cc0dccd
Compare
7e220b3
to
525cd23
Compare
This PR tries to introduce a standalone Javac jar from the repository https://github.com/JaroslavTulach/nb-javac for Javac API access within our project. The benefit is that it allows the language server to support latest language features without requiring user to run the language server with the latest JDK.
This PR is an experiment PR, not full ready yet. It faces some issues with new approach, and I open the PR first for suggestions and feedback.