pedro-w commented on issue #8560: URL: https://github.com/apache/netbeans/issues/8560#issuecomment-2994165635
I've done a bit more looking at this, and I believe it is down to way that NB checks for accessible classes (accessible in the sense of public / private etc). The Javadoc hint does not report missing doc comments if the element in question is not accessible. There is an extra code path for understanding accessibility in modular projects (by parsing the module-info.java). There appears to be a bug that anything in a module is marked as being not accessible. I think this is down to the following (`cc` is a `org.netbeans.api.java.source.CompilationController` atteched to the module-info file here) https://github.com/apache/netbeans/blob/2c07bda77e5b22ab3d601ea39b33f74a4892b2a0/java/java.api.common/src/org/netbeans/modules/java/api/common/queries/ModuleInfoAccessibilityQueryImpl.java#L268-L281 I think it's supposed get the one and only TypeDecl from the compilation unit, which will be the `module {}` block. Unfortunately `getTypeDecls` does not return the module block, there is another function `getModule` for that. I applied this simple patch and it made my example project (above) work correctly. ``` diff --git a/java/java.api.common/src/org/netbeans/modules/java/api/common/queries/ModuleInfoAccessibilityQueryImpl.java b/java/java.api.common/src/org/netbeans/modules/java/api/common/queries/ModuleInfoAccessibilityQueryImpl.java index 65d735c600..288ded64df 100644 --- a/java/java.api.common/src/org/netbeans/modules/java/api/common/queries/ModuleInfoAccessibilityQueryImpl.java +++ b/java/java.api.common/src/org/netbeans/modules/java/api/common/queries/ModuleInfoAccessibilityQueryImpl.java @@ -266,8 +266,9 @@ final class ModuleInfoAccessibilityQueryImpl implements AccessibilityQueryImplem src.runUserActionTask((cc) -> { cc.toPhase(JavaSource.Phase.RESOLVED); final CompilationUnitTree cu = cc.getCompilationUnit(); - if (cu.getTypeDecls().size() == 1 && cu.getTypeDecls().get(0) instanceof ModuleTree) { - final ModuleTree mt = (ModuleTree) cu.getTypeDecls().get(0); + // Module tree or may be null + ModuleTree mt = cu.getModule(); + if (mt != null) { final ModuleElement me = (ModuleElement) cc.getTrees().getElement(TreePath.getPath(cu, mt)); if (me != null) { for (ModuleElement.Directive directive : me.getDirectives()) { ``` However the whole hint system is very complicated code so not sure if this is correct or may have implications elsewhere. Any comments welcome. ps. AFAICS it's not (directly) related to Ant. pps. the module where this is, Java Common Project API, has Source level 1.8, can this be upgraded? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
