Skip to content

Suppress incubating module warning to retain -Werror#144798

Merged
ChrisHegarty merged 7 commits intoelastic:mainfrom
ChrisHegarty:suppress-incubating-warning
Mar 25, 2026
Merged

Suppress incubating module warning to retain -Werror#144798
ChrisHegarty merged 7 commits intoelastic:mainfrom
ChrisHegarty:suppress-incubating-warning

Conversation

@ChrisHegarty
Copy link
Copy Markdown
Contributor

@ChrisHegarty ChrisHegarty commented Mar 23, 2026

Summary

The simdvec and swisshash modules use jdk.incubator.vector, which causes javac to emit a mandatory warning:

warning: using incubating module(s): jdk.incubator.vector

On JDK 21 this warning has no named lint category - -Xlint:-incubating was only added in JDK 22. Since the build enforces -Werror, both modules had to remove -Werror as a workaround, meaning 29+ source files compile without warnings-as-errors.

This PR restores -Werror for all source files by suppressing the incubating warning centrally in ElasticsearchJavaBasePlugin.

The -Xlint:none trick

On JDK 21, the incubating warning is a "mandatory" warning outside the named -Xlint category system. -Xlint:none suppresses it, and when followed by -Xlint:all,..., javac re-enables only the named categories — the unnamed incubating warning stays suppressed.

JDK -Xlint:none then -Xlint:all,... Incubating suppressed? Real warnings caught?
21 Yes — incubating is unnamed, stays suppressed Yes Yes
22–24 Yes — incubating is named but not re-enabled by all after none Yes Yes
25 No — incubating is re-enabled by all No Yes

For JDK 25+, -incubating must be added to the -Xlint exclusion list. The fix is version-aware: it always prepends -Xlint:none, and additionally excludes -incubating when the compiler JDK is >= 22.

Changes

  • ElasticsearchJavaBasePlugin.java - Prepend -Xlint:none before -Xlint:all,... to suppress the mandatory incubating warning. Add version-aware -incubating exclusion for JDK 22+ compilers.
  • simdvec/build.gradle - Remove options.compilerArgs -= '-Werror' workaround.
  • swisshash/build.gradle - Remove options.compilerArgs -= '-Werror' workaround.

Relates #144797

Made with support from AI tooling.

Prepend -Xlint:none before -Xlint:all,... in ElasticsearchJavaBasePlugin
to suppress the mandatory "using incubating module(s)" warning that javac
emits when jdk.incubator.vector is used. On JDK 21 this warning has no
named lint category and cannot be individually suppressed (-Xlint:-incubating
was added in JDK 22). -Xlint:none clears all warnings including this
mandatory one, then -Xlint:all,... re-enables only the named categories.

For JDK 22+ compilers, -incubating is also added to the exclusion list
to handle JDK 25+ where -Xlint:all re-enables the now-named category.

This allows removing the -Werror workarounds from simdvec and swisshash
build.gradle files, restoring warnings-as-errors for all source files.

Relates elastic#144797

Made-with: Cursor
@ChrisHegarty ChrisHegarty requested a review from a team as a code owner March 23, 2026 18:12
@elasticsearchmachine elasticsearchmachine added v9.4.0 needs:triage Requires assignment of a team area label labels Mar 23, 2026
@ChrisHegarty ChrisHegarty added :Search Relevance/Vectors Vector search Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch labels Mar 23, 2026
@elasticsearchmachine elasticsearchmachine removed the needs:triage Requires assignment of a team area label label Mar 23, 2026
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-search-relevance (Team:Search Relevance)

@ChrisHegarty ChrisHegarty added :Delivery/Build Build or test infrastructure >refactoring labels Mar 23, 2026
@elasticsearchmachine elasticsearchmachine added the Team:Delivery Meta label for Delivery team label Mar 23, 2026
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-delivery (Team:Delivery)

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 23, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: b0c2f7ad-d1b1-4090-9cdd-7c04bdc64402

📥 Commits

Reviewing files that changed from the base of the PR and between 8e50c1c and 44c3662.

📒 Files selected for processing (3)
  • build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/ElasticsearchJavaBasePlugin.java
  • libs/simdvec/build.gradle
  • libs/swisshash/build.gradle
💤 Files with no reviewable changes (2)
  • libs/swisshash/build.gradle
  • libs/simdvec/build.gradle

📝 Walkthrough

Walkthrough

The pull request modifies Java compilation configuration across multiple build files. The Elasticsearch base build plugin's javac lint handling was adjusted to first disable all lint checks, then selectively re-enable specific categories. For compiler major version 22 and above, the incubating warning is additionally excluded from the re-enabled categories, while the -Werror flag remains active. Simultaneously, the -Werror flag (treating warnings as compilation errors) was removed from build configurations in the simdvec and swisshash modules, allowing those modules to compile despite warning conditions.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • 🛠️ Update Documentation: Commit on current branch
  • 🛠️ Update Documentation: Create PR

Comment @coderabbitai help to get the list of available commands and usage tips.

@ChrisHegarty ChrisHegarty requested a review from rjernst March 24, 2026 17:37
Copy link
Copy Markdown
Member

@thecoop thecoop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Niiiiiice

@ChrisHegarty ChrisHegarty merged commit 5bff441 into elastic:main Mar 25, 2026
36 checks passed
@ChrisHegarty ChrisHegarty deleted the suppress-incubating-warning branch March 25, 2026 10:57
eranweiss-elastic pushed a commit to eranweiss-elastic/elasticsearch that referenced this pull request Mar 25, 2026
Prepend -Xlint:none before -Xlint:all,... in ElasticsearchJavaBasePlugin
to suppress the mandatory "using incubating module(s)" warning that javac
emits when jdk.incubator.vector is used. On JDK 21 this warning has no
named lint category and cannot be individually suppressed (-Xlint:-incubating
was added in JDK 22). -Xlint:none clears all warnings including this
mandatory one, then -Xlint:all,... re-enables only the named categories.

For JDK 22+ compilers, -incubating is also added to the exclusion list
to handle JDK 25+ where -Xlint:all re-enables the now-named category.

This allows removing the -Werror workarounds from simdvec and swisshash
build.gradle files, restoring warnings-as-errors for all source files.
ChrisHegarty added a commit that referenced this pull request Mar 26, 2026
This is step 2 of #144797. I'm merging the `main21` source set into `main` in the simdvec module, eliminating one level of MR-JAR complexity.

The `main21` source set existed because it uses `jdk.incubator.vector`, which emitted an unsuppressible warning on JDK 21 that was incompatible with `-Werror`. Now that I've suppressed that warning centrally in #144798, there is no longer a reason to keep these files in a separate source set.

Specifically:
  - I moved all 33 source files from `src/main21/java/` into `src/main/java/`.
  - I replaced the two stub classes in `main` (`VectorScorerFactoryImpl`,
    `ESVectorizationProvider`) with their real `main21` implementations. The
    stubs only existed to satisfy the compiler and threw
    `UnsupportedOperationException` at runtime.
  - I moved `IndexInputUtilsTests` from `src/test21/` into `src/test/`.
  - I deleted the `src/main21/` and `src/test21/` directories entirely.
  - I updated `build.gradle` to pass `--add-modules` and `--add-reads` to the
    main `compileJava` task instead of `compileMain21Java`.
  - I updated the `module-info.java` Javadoc to reflect the simplified layout.
  
  I've left the `main22` source set and the MR-JAR plugin in place for now;
  I'll address those in subsequent steps.
seanzatzdev pushed a commit to seanzatzdev/elasticsearch that referenced this pull request Mar 26, 2026
This is step 2 of elastic#144797. I'm merging the `main21` source set into `main` in the simdvec module, eliminating one level of MR-JAR complexity.

The `main21` source set existed because it uses `jdk.incubator.vector`, which emitted an unsuppressible warning on JDK 21 that was incompatible with `-Werror`. Now that I've suppressed that warning centrally in elastic#144798, there is no longer a reason to keep these files in a separate source set.

Specifically:
  - I moved all 33 source files from `src/main21/java/` into `src/main/java/`.
  - I replaced the two stub classes in `main` (`VectorScorerFactoryImpl`,
    `ESVectorizationProvider`) with their real `main21` implementations. The
    stubs only existed to satisfy the compiler and threw
    `UnsupportedOperationException` at runtime.
  - I moved `IndexInputUtilsTests` from `src/test21/` into `src/test/`.
  - I deleted the `src/main21/` and `src/test21/` directories entirely.
  - I updated `build.gradle` to pass `--add-modules` and `--add-reads` to the
    main `compileJava` task instead of `compileMain21Java`.
  - I updated the `module-info.java` Javadoc to reflect the simplified layout.
  
  I've left the `main22` source set and the MR-JAR plugin in place for now;
  I'll address those in subsequent steps.
seanzatzdev pushed a commit to seanzatzdev/elasticsearch that referenced this pull request Mar 27, 2026
Prepend -Xlint:none before -Xlint:all,... in ElasticsearchJavaBasePlugin
to suppress the mandatory "using incubating module(s)" warning that javac
emits when jdk.incubator.vector is used. On JDK 21 this warning has no
named lint category and cannot be individually suppressed (-Xlint:-incubating
was added in JDK 22). -Xlint:none clears all warnings including this
mandatory one, then -Xlint:all,... re-enables only the named categories.

For JDK 22+ compilers, -incubating is also added to the exclusion list
to handle JDK 25+ where -Xlint:all re-enables the now-named category.

This allows removing the -Werror workarounds from simdvec and swisshash
build.gradle files, restoring warnings-as-errors for all source files.
seanzatzdev pushed a commit to seanzatzdev/elasticsearch that referenced this pull request Mar 27, 2026
This is step 2 of elastic#144797. I'm merging the `main21` source set into `main` in the simdvec module, eliminating one level of MR-JAR complexity.

The `main21` source set existed because it uses `jdk.incubator.vector`, which emitted an unsuppressible warning on JDK 21 that was incompatible with `-Werror`. Now that I've suppressed that warning centrally in elastic#144798, there is no longer a reason to keep these files in a separate source set.

Specifically:
  - I moved all 33 source files from `src/main21/java/` into `src/main/java/`.
  - I replaced the two stub classes in `main` (`VectorScorerFactoryImpl`,
    `ESVectorizationProvider`) with their real `main21` implementations. The
    stubs only existed to satisfy the compiler and threw
    `UnsupportedOperationException` at runtime.
  - I moved `IndexInputUtilsTests` from `src/test21/` into `src/test/`.
  - I deleted the `src/main21/` and `src/test21/` directories entirely.
  - I updated `build.gradle` to pass `--add-modules` and `--add-reads` to the
    main `compileJava` task instead of `compileMain21Java`.
  - I updated the `module-info.java` Javadoc to reflect the simplified layout.
  
  I've left the `main22` source set and the MR-JAR plugin in place for now;
  I'll address those in subsequent steps.
mamazzol pushed a commit to mamazzol/elasticsearch that referenced this pull request Mar 30, 2026
This is step 2 of elastic#144797. I'm merging the `main21` source set into `main` in the simdvec module, eliminating one level of MR-JAR complexity.

The `main21` source set existed because it uses `jdk.incubator.vector`, which emitted an unsuppressible warning on JDK 21 that was incompatible with `-Werror`. Now that I've suppressed that warning centrally in elastic#144798, there is no longer a reason to keep these files in a separate source set.

Specifically:
  - I moved all 33 source files from `src/main21/java/` into `src/main/java/`.
  - I replaced the two stub classes in `main` (`VectorScorerFactoryImpl`,
    `ESVectorizationProvider`) with their real `main21` implementations. The
    stubs only existed to satisfy the compiler and threw
    `UnsupportedOperationException` at runtime.
  - I moved `IndexInputUtilsTests` from `src/test21/` into `src/test/`.
  - I deleted the `src/main21/` and `src/test21/` directories entirely.
  - I updated `build.gradle` to pass `--add-modules` and `--add-reads` to the
    main `compileJava` task instead of `compileMain21Java`.
  - I updated the `module-info.java` Javadoc to reflect the simplified layout.
  
  I've left the `main22` source set and the MR-JAR plugin in place for now;
  I'll address those in subsequent steps.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Delivery/Build Build or test infrastructure >refactoring :Search Relevance/Vectors Vector search Team:Delivery Meta label for Delivery team Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants