-
Notifications
You must be signed in to change notification settings - Fork 875
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
For nb.org projects, use the correct nbjavac prepend for the internal (boot)classpath. #5174
For nb.org projects, use the correct nbjavac prepend for the internal (boot)classpath. #5174
Conversation
… (boot)classpath.
bootstrapAPIs.add(ext); | ||
} | ||
} | ||
buildDefaults.put(ClassPathProviderImpl.BOOTCLASSPATH_PREPEND, bootstrapAPIs.stream().collect(Collectors.joining(File.pathSeparator))); |
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.
Would it be more compact to say
String path = Stream.of(javacLibrary.getClassPathExtensions().split(Pattern.quote(File.pathSeparator))).
filter(ext -> ext.endsWith("-api.jar")).
collect(Collectors.joining(File.pathSeparator)));
buildDefaults.put(ClassPathProviderImpl.BOOTCLASSPATH_PREPEND, path);
or even extract path calculation into a private method with meaningful name
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.
If I understand the idea correctly, the indention is, that code completion and type resolution of the IDE will work correctly for projects using the bundled javac. This is very good @jlahoda. However I checked java.source.base
module and noticed, that only a subset of problems is gone. The module uses classes from the com.sun.tools.javac.tree
package, which is in nb-javac-jdk-19+33.jar
. I tested with this change and all problems are gone:
--- a/apisupport/apisupport.ant/src/org/netbeans/modules/apisupport/project/Evaluator.java
+++ b/apisupport/apisupport.ant/src/org/netbeans/modules/apisupport/project/Evaluator.java
@@ -426,15 +426,9 @@
if (type == NbModuleType.NETBEANS_ORG && "true".equals(projectProperties.getProperties().get("requires.nb.javac"))) {
ModuleEntry javacLibrary = ml.getEntry("org.netbeans.libs.javacapi");
if (javacLibrary != null) {
- List<String> bootstrapAPIs = new ArrayList<>();
- for (String ext : javacLibrary.getClassPathExtensions().split(Pattern.quote(File.pathSeparator))) {
- if (ext.endsWith("-api.jar")) {
- bootstrapAPIs.add(ext);
+ buildDefaults.put(ClassPathProviderImpl.BOOTCLASSPATH_PREPEND, javacLibrary.getClassPathExtensions());
}
}
- buildDefaults.put(ClassPathProviderImpl.BOOTCLASSPATH_PREPEND, bootstrapAPIs.stream().collect(Collectors.joining(File.pathSeparator)));
- }
- }
baseEval = PropertyUtils.sequentialPropertyEvaluator(predefs, providers.toArray(new PropertyProvider[providers.size()]));
That's what I don't want to do blindly - that would mean that any module could seemingly use javac internals, which does not sound right. (There are many limitations on this, so some modules have an impl. dependency even though they should not, the impl might be partially visible in the editor anyway, and the build also uses everything including the impl. OTOH, runtime is strict, and I don't think we should make the situation worse.) But, we may be able to parse the javac dependency, and if it is an impl. dependency, use even the implementation. (Of course, the very correct way would be to only use exported packages, but we don't do that in the IDE for anything.) Please see 441cd88. |
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.
Approach looks good to me and seems to work. Thank you!
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.
It would be helpful to get this fixed. Otherwise working with javac
sources is often a bit off for me.
Lets get this in. |
When building the bootclasspath for APISupport (nb.org modules in particular), lookup the correct nbjavac API jar in the particular repository, and prepend it to the bootclasspath.
^Add meaningful description above
By opening a pull request you confirm that, unless explicitly stated otherwise, the changes -
Please make sure (eg.
git log
) that all commits have a valid name and email address for you in the Author field.If you're a first time contributor, see the Contributing guidelines for more information.
If you're a committer, please label the PR before pressing "Create pull request" so that the right test jobs can run.