Skip to content

[NETBEANS-4044] Fixing patching of modular libraries #4391

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

Merged
merged 3 commits into from
Jul 19, 2022

Conversation

jlahoda
Copy link
Contributor

@jlahoda jlahoda commented Jul 17, 2022

Consider a binary library with an attached source. When opening a source file for the library, if the library is non-modular, the binary will be on the classpath, and the source will be able to refer to it. When the library is modular, javac will not look at the classpath anymore, but will try to lookup module-info and other dependencies on source and output path. So, we need to make sure the output path contains the binary library, so that the lookups work. This is what this patch is trying to achieve.


^Add meaningful description above

By opening a pull request you confirm that, unless explicitly stated otherwise, the changes -

  • are all your own work, and you have the right to contribute them.
  • are contributed solely under the terms and conditions of the Apache License 2.0 (see section 5 of the license for more information).

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.

@matthiasblaesing
Copy link
Contributor

I tested this change and it works as described in #4044 (comment). However the testfailure from travis of 12666.13 Test Java modules with nb-javac on Java 8 is locally reproducible if you run the unittests locally with JDK-8.

@matthiasblaesing
Copy link
Contributor

Both github-actions and travis are happy now. I think this would be worth to be targeted for NB15. @jlahoda What do you think? As branching of has happend, this would need to be retargeted for delivery.

@mbien mbien added Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) kind:bug Bug report or fix labels Jul 19, 2022
@mbien mbien added this to the NB15 milestone Jul 19, 2022
@mbien
Copy link
Member

mbien commented Jul 19, 2022

@matthiasblaesing @neilcsmith-net i just added the NB15 label, maybe we can get this into RC2 or so. Unless @jlahoda doesn't want to.

@neilcsmith-net
Copy link
Member

@mbien we can get it in RC1 if we're quick about it! Going to change the base branch. If it merges cleanly I will do.

@neilcsmith-net neilcsmith-net changed the base branch from master to delivery July 19, 2022 09:56
@neilcsmith-net
Copy link
Member

Am going to merge this into delivery. It doesn't seem to be a full fix for #4044 though. Using @matthiasblaesing example project, docs in completion and navigate to source now work, but the reported Show Javadoc failure still applies. This can be fixed by adding a module-info to the project. I don't think that's unexpected. I think we need a better way of inferring a module name from an Element than I added in #4363

@neilcsmith-net neilcsmith-net merged commit 9f1b04a into apache:delivery Jul 19, 2022
@neilcsmith-net
Copy link
Member

First run of RC1 and I see a bunch of NPEs with the following stack trace -

SEVERE [org.openide.util.RequestProcessor]: Error in RequestProcessor org.netbeans.modules.parsing.ui.indexing.errors.ErrorAnnotator$1
java.lang.NullPointerException: Cannot invoke "java.util.Set.stream()" because "this.moduleLocations" is null
	at org.netbeans.modules.java.source.parsing.PatchModuleFileManager.fixLocation(PatchModuleFileManager.java:299)
	at org.netbeans.modules.java.source.parsing.PatchModuleFileManager.getJavaFileForInput(PatchModuleFileManager.java:259)
	at org.netbeans.modules.java.source.parsing.ProxyFileManager.getJavaFileForInput(ProxyFileManager.java:392)
	at com.sun.tools.javac.code.ModuleFinder.getModuleInfoFromLocation(ModuleFinder.java:285)
	at com.sun.tools.javac.code.ModuleFinder.findSingleModule(ModuleFinder.java:200)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) kind:bug Bug report or fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Library Javadoc not performed from source code context menu
4 participants