This issue has been created
There are 2 updates, 4 comments.
 
 
XWiki Commons / cid:jira-generated-image-avatar-579cb179-1f39-43e3-9a40-c1b3fe3cf88e XCOMMONS-3772 Open

Don't run javac lint checks on generated sources

 
View issue   ยท   Add comment
 

Issue created

 
cid:jira-generated-image-avatar-2715c6aa-bbf7-4ebc-aaef-d8cb81265e30 Vincent Massol created this issue on 07/Sep/26 19:40
 
Summary: Don't run javac lint checks on generated sources
Issue Type: cid:jira-generated-image-avatar-579cb179-1f39-43e3-9a40-c1b3fe3cf88e Improvement
Assignee: Unassigned
Components: Development Issues only
Created: 07/Sep/26 19:40
Priority: cid:jira-generated-image-static-major-fc185c01-2016-4e1d-8e04-aa69c31bee6d Major
Reporter: Vincent Massol
Description:

The Maven build reports 120 javac lint warnings on machine-generated sources, and none of them can be fixed since we don't control the code generators:* xwiki-platform-query-jpql-parser: 100 rawtypes warnings from the SableCC-generated parser and AST nodes. SableCC predates generics and is unmaintained, and it generates code such as ArrayList list = new ArrayList();.

  • xwiki-rendering-wikimodel: 6 this-escape and 6 static warnings from the JavaCC-generated scanners. JavaCC generates the *TokenManager class body itself, so there is nowhere to put a @SuppressWarnings.
  • xwiki-commons-repository-model: 4 dep-ann and 4 deprecation warnings from the XJC-generated JAXB model. XJC copies the @deprecated note from the XSD into javadoc but does not emit the @Deprecated annotation. That raises dep-ann on the declarations, and it also raises deprecation on the generated fluent accessors, which call the deprecated getters and are not annotated either.

These warnings are what prevents enabling -Werror, which xwiki-commons-pom has carried as a TODO for a long time ("At some point, we should turn on failing on warnings since they can be real errors and they keep growing on our build logs"): we cannot fail the build on warnings while it contains warnings that are impossible to fix.

Note that -Xlint applies to a whole javac invocation and not to a source path, so switching a category off for a module also stops checking that module's hand-written sources. So for modules that mix generated and hand-written sources, compile the generated source root in its own maven-compiler-plugin execution with -Xlint:none and restrict the default execution to src/main/java, which keeps the hand-written sources fully checked. Add a xwiki.compiler.xlint property to xwiki-commons-pom for the whole-module cases, that is modules containing only generated sources, and later the legacy and Jakarta bridge modules whose very purpose is to call deprecated APIs.

We already made this choice for our other linters, and this only makes javac agree with them: xwiki-platform-query-jpql-parser excludes the generated packages from Checkstyle, xwiki-commons-repository-model and xwiki-rendering-wikimodel set xwiki.checkstyle.skip, and xwiki-commons-pom silences Sonar's java:S1133 for legacy modules.

Note that this applies to every project inheriting the XWiki parent POM, including xwiki-contrib extensions. See the proposal on the forum https://forum.xwiki.org/t/stop-running-javac-lint-checks-on-generated-code/18828.

 
 

2 updates

 
cid:jira-generated-image-avatar-2715c6aa-bbf7-4ebc-aaef-d8cb81265e30 Changes by Vincent Massol on 07/Sep/26 19:42
 
Description: The Maven build reports 120 javac lint warnings on machine \ -generated sources, and none of them can be fixed since we don't control the code generators:

* {{xwiki \ -platform \ -query \ -jpql \ -parser}}: 100 {{rawtypes}} warnings from the SableCC \ -generated parser and AST nodes. SableCC predates generics and is unmaintained, and it generates code such as {{ArrayList list = new ArrayList \ ( \ );}}.
* {{xwiki
\ -rendering \ -wikimodel}}: 6 {{this \ -escape}} and 6 {{static}} warnings from the JavaCC \ -generated scanners. JavaCC generates the {{ \ *TokenManager}} class body itself, so there is nowhere to put a {{@SuppressWarnings}}.
* {{xwiki
\ -commons \ -repository \ -model}}: 4 {{dep \ -ann}} and 4 {{deprecation}} warnings from the XJC \ -generated JAXB model. XJC copies the {{@deprecated}} note from the XSD into javadoc but does not emit the {{@Deprecated}} annotation. That raises {{dep \ -ann}} on the declarations, and it also raises {{deprecation}} on the generated fluent accessors, which call the deprecated getters and are not annotated either.

These warnings are what prevents enabling {{
\ -Werror}}, which {{xwiki \ -commons \ -pom}} has carried as a TODO for a long time \ ("At some point, we should turn on failing on warnings since they can be real errors and they keep growing on our build logs" \ ): we cannot fail the build on warnings while it contains warnings that are impossible to fix.

Note that {{
\ -Xlint}} applies to a whole javac invocation and not to a source path, so switching a category off for a module also stops checking that module's hand \ -written sources. So for modules that mix generated and hand \ -written sources, compile the generated source root in its own {{maven \ -compiler \ -plugin}} execution with {{ \ -Xlint:none}} and restrict the default execution to {{src/main/java}}, which keeps the hand \ -written sources fully checked. Add a {{xwiki.compiler.xlint}} property to {{xwiki \ -commons \ -pom}} for the whole \ -module cases, that is modules containing only generated sources, and later the legacy and Jakarta bridge modules whose very purpose is to call deprecated APIs.

We already made this choice for our other linters, and this only makes javac agree with them: {{xwiki
\ -platform \ -query \ -jpql \ -parser}} excludes the generated packages from Checkstyle, {{xwiki \ -commons \ -repository \ -model}} and {{xwiki \ -rendering \ -wikimodel}} set {{xwiki.checkstyle.skip}}, and {{xwiki \ -commons \ -pom}} silences Sonar's {{java:S1133}} for legacy modules.

Note that this applies to every project inheriting the XWiki parent POM, including xwiki
\ -contrib extensions. See the proposal on the forum [ https://forum.xwiki.org/t/stop \ -running \ -javac \ -lint \ -checks \ -on \ -generated \ -code/18828 |https://forum . xwiki.org/t/stop-running-javac-lint-checks-on-generated-code/18828].

Assignee: Vincent Massol
 
 

4 comments

 
cid:jira-generated-image-avatar-2715c6aa-bbf7-4ebc-aaef-d8cb81265e30 Vincent Massol on 07/Sep/26 19:43
 

PRs (drafts until the forum proposal is agreed):* xwiki-commons: https://github.com/xwiki/xwiki-commons/pull/1957 (adds the xwiki.compiler.xlint property and clears the 8 XJC warnings)

The rendering and platform ones need the commons one merged first, since they rely on the new parent POM.

 
cid:jira-generated-image-avatar-2715c6aa-bbf7-4ebc-aaef-d8cb81265e30 Vincent Massol on 07/Sep/26 19:44
 
PRs \ (drafts until the forum proposal is agreed \ ):

* xwiki \ -commons: [ https://github.com/xwiki/xwiki \ -commons/pull/1957 |https://github.com/xwiki/xwiki-commons/pull/1957] \ (adds the {{xwiki.compiler.xlint}} property and clears the 8 XJC warnings \ )
* xwiki
\ -rendering: [ https://github.com/xwiki/xwiki \ -rendering/pull/431 |https://github.com/xwiki/xwiki-rendering/pull/431] \ (clears the 12 JavaCC warnings \ )
* xwiki
\ -platform: [ https://github.com/xwiki/xwiki \ -platform/pull/6333 |https://github.com/xwiki/xwiki-platform/pull/6333] \ (clears the 100 SableCC warnings \ )

The rendering and platform ones need the commons one merged first, since they rely on the new parent POM.


 
cid:jira-generated-image-avatar-2715c6aa-bbf7-4ebc-aaef-d8cb81265e30 Vincent Massol on 07/Sep/26 19:46
 

Intro line before a list:* first item

  • second item

Trailing paragraph.

 
cid:jira-generated-image-avatar-2715c6aa-bbf7-4ebc-aaef-d8cb81265e30 Vincent Massol on 07/Sep/26 19:46
 
Intro line before a list:* first item
* second item

Trailing paragraph.