Skip to content

FIX: Fix compiler warnings and enable -Werror#548

Open
Jamesr51d wants to merge 1 commit into
mainfrom
fix/compiler-warnings
Open

FIX: Fix compiler warnings and enable -Werror#548
Jamesr51d wants to merge 1 commit into
mainfrom
fix/compiler-warnings

Conversation

@Jamesr51d

Copy link
Copy Markdown
Contributor

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

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.
@Jamesr51d Jamesr51d requested a review from justadreamer June 19, 2026 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

java: fix Java21 Warnings

1 participant