Repository navigation
Fix init order of PlatformDependent0 fields - #15077
Merged
Merged
Conversation
Motivation: After netty#14975, EXPLICIT_NO_UNSAFE_CAUSE has a dependency to JAVA_VERSION, which is initialized after it. When explicitNoUnsafeCause0() tries to set io.netty.noUnsafe to true by default on Java 24, it fails, because javaVersion() always returns 0 at that point. Also, isAndroid0() is called twice, once in javaVersion0() and once to initialize IS_ANDROID. This is not a bug or a performance issue, but it does have a visible side-effect when debug logging is enabled. Modification: The declaration of EXPLICIT_NO_UNSAFE_CAUSE is moved after JAVA_VERSION, ensuring javaVersion() returns the correct version when explicitNoUnsafeCause0() calls it. IS_ANDROID is also moved before JAVA_VERSION, such that the isAndroid0() method is called only once. Result: Fixes netty#14942 correctly
chrisvest
approved these changes
Apr 24, 2025
Member
|
@Spasi thanks! |
chrisvest
pushed a commit
to chrisvest/netty
that referenced
this pull request
Apr 25, 2025
Motivation: After netty#14975, `EXPLICIT_NO_UNSAFE_CAUSE` has a dependency to `JAVA_VERSION`, which is initialized after it. When `explicitNoUnsafeCause0()` tries to set `io.netty.noUnsafe` to true by default on Java 24, it fails, because `javaVersion()` always returns 0 at that point. Also, `isAndroid0()` is called twice, once in `javaVersion0()` and once to initialize `IS_ANDROID`. This is not a bug or a performance issue, but it does have a visible side-effect when debug logging is enabled. Modification: The declaration of `EXPLICIT_NO_UNSAFE_CAUSE` is moved after `JAVA_VERSION`, ensuring `javaVersion()` returns the correct version when `explicitNoUnsafeCause0()` calls it. `IS_ANDROID` is also moved before `JAVA_VERSION`, such that the `isAndroid0()` method is called only once. Result: Fixes netty#14942 correctly
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.
Motivation:
After #14975,
EXPLICIT_NO_UNSAFE_CAUSEhas a dependency toJAVA_VERSION, which is initialized after it. WhenexplicitNoUnsafeCause0()tries to setio.netty.noUnsafeto true by default on Java 24, it fails, becausejavaVersion()always returns 0 at that point.Also,
isAndroid0()is called twice, once injavaVersion0()and once to initializeIS_ANDROID. This is not a bug or a performance issue, but it does have a visible side-effect when debug logging is enabled.Modification:
The declaration of
EXPLICIT_NO_UNSAFE_CAUSEis moved afterJAVA_VERSION, ensuringjavaVersion()returns the correct version whenexplicitNoUnsafeCause0()calls it.IS_ANDROIDis also moved beforeJAVA_VERSION, such that theisAndroid0()method is called only once.Result:
Fixes #14942 correctly