FIX: Fix compiler warnings and enable -Werror#548
Open
Jamesr51d wants to merge 1 commit into
Open
Conversation
JDK 21+ surfaces two lint categories the build did not previously act on. This change clears them across all modules and turns on warnings as errors to prevent regressions. Finalize deprecated for removal (20 SWIG-generated classes): On JDK 21+ java.lang.Object.finalize is annotated deprecated for removal, so the warning belongs to the "removal" lint category. The existing @SuppressWarnings("deprecation") does not cover that category, so it is widened to @SuppressWarnings({"deprecation", "removal"}), which is also what current SWIG emits. Possible 'this' escape before a subclass is fully initialised: MultiDeviceDataCloud is now final. Its constructors call the overridable put method, inherited from DataBase, before the object is fully built, which is exactly the hazard the lint flags. Marking the class final removes any possibility of a subclass override running against a half constructed instance, so javac no longer reports the escape and no suppression is required. VectorStringSwig is SWIG-generated, so any edit to it is overwritten the next time the native build regenerates the bindings. Its two constructors therefore keep a narrow @SuppressWarnings("this-escape") as a stopgap. Enable -Werror: The javac -Werror argument in the root pom maven-compiler-plugin configuration is uncommented, so any warning now fails the build. Verified by compiling the full reactor, all four modules including main and test sources, on JDK 25 with -Werror, which succeeds with no warnings reported.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
JDK 21+ surfaces two lint categories the build did not previously act on. This change clears them across all modules and turns on warnings as errors to prevent regressions.
Finalize deprecated for removal (20 SWIG-generated classes): On JDK 21+ java.lang.Object.finalize is annotated deprecated for removal, so the warning belongs to the "removal" lint category. The existing @SuppressWarnings("deprecation") does not cover that category, so it is widened to @SuppressWarnings({"deprecation", "removal"}), which is also what current SWIG emits.
Possible 'this' escape before a subclass is fully initialised: MultiDeviceDataCloud is now final. Its constructors call the overridable put method, inherited from DataBase, before the object is fully built, which is exactly the hazard the lint flags. Marking the class final removes any possibility of a subclass override running against a half constructed instance, so javac no longer reports the escape and no suppression is required.
VectorStringSwig is SWIG-generated, so any edit to it is overwritten the next time the native build regenerates the bindings. Its two constructors therefore keep a narrow @SuppressWarnings("this-escape") as a stopgap.
Enable -Werror:
The javac -Werror argument in the root pom maven-compiler-plugin configuration is uncommented, so any warning now fails the build. Verified by compiling the full reactor, all four modules including main and test sources, on JDK 25 with -Werror, which succeeds with no warnings reported.
Closes #363