Skip to content

Raise the minimum Java version to 21. - #781

Open
blackwinter wants to merge 3 commits into
masterfrom
765-raiseJavaVersionTo21
Open

Raise the minimum Java version to 21.#781
blackwinter wants to merge 3 commits into
masterfrom
765-raiseJavaVersionTo21

Conversation

@blackwinter

@blackwinter blackwinter commented Jul 10, 2026

Copy link
Copy Markdown
Member

Resolves #765.

  • ByteBuddy agent (used by EqualsVerifier and Mockito) requires dynamic agent loading to be enabled (see also Mockito documentation: Explicitly setting up instrumentation for inline mocking (Java 21+)).
  • Suppress "this-escape" warnings (should eventually be solved by either refactoring or finalizing methods/classes; see also JDK-8299995, introduced in JDK 21).
  • Replace deprecated Weak Reference check with designated replacement (deprecated in JDK 16; see also deprecation notice).

Depends on both #779 and #780.

@blackwinter
blackwinter requested a review from fsteeg July 10, 2026 14:05
@blackwinter
blackwinter changed the base branch from 765-provideJava21ForwardCompatibility to master July 13, 2026 09:05
@blackwinter
blackwinter force-pushed the 765-raiseJavaVersionTo21 branch from c4eea5d to 214272a Compare July 14, 2026 11:09
See also Mockito documentation: [Explicitly setting up instrumentation for inline mocking (Java 21+)](https://javadoc.io/doc/org.mockito/mockito-core/latest/org.mockito/org/mockito/Mockito.html#0.3)

--------

* JDK 21:

WARNING: A Java agent has been loaded dynamically (.../byte-buddy-agent-1.12.19.jar)
WARNING: If a serviceability tool is in use, please run with -XX:+EnableDynamicAgentLoading to hide this warning
WARNING: If a serviceability tool is not in use, please run with -Djdk.instrument.traceUsage for more information
WARNING: Dynamic loading of agents will be disallowed by default in a future release
Should actually be solved by either refactoring or `final`izing methods/classes.

See also: https://bugs.openjdk.org/browse/JDK-8299995

--------

* JDK 21:

- "warning: [this-escape] possible 'this' escape before subclass is fully initialized"
- "warning: [this-escape] previous possible 'this' escape happens here via invocation"
…765)

"This method was originally specified to test if a reference object has been cleared and enqueued but was never implemented to do this test. This method could be misused due to the inherent race condition or without an associated `ReferenceQueue`. An application relying on this method to release critical resources could cause serious performance issue. An application should use `ReferenceQueue` to reliably determine what reference objects that have been enqueued or `refersTo(null)` to determine if this reference object has been cleared."

--------

* JDK 21: "warning: [deprecation] isEnqueued() in Reference has been deprecated"
@blackwinter
blackwinter force-pushed the 765-raiseJavaVersionTo21 branch from 214272a to ddf031d Compare July 14, 2026 11:17
@blackwinter

Copy link
Copy Markdown
Member Author

Rebased to include #779 and #780, so the build is passing now (after switching the GitHub Action workflow to 21 as well, in order to run the Metafix integration tests with the correct Java version).

@fsteeg fsteeg assigned blackwinter and unassigned fsteeg Jul 14, 2026
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.

Raise the minimum Java version to 21

2 participants