HDDS-11076. NoSuchMethodError: ByteBuffer.position compiling with Java 9+, running with Java 8 #6897
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.
What changes were proposed in this pull request?
Building Ozone with Java 9+ (but still targeting Java 8 with
javac.version=8) and running with Java 8 results in:It can be reproduced in Hadoop compatibility tests, because Hadoop images still ship with Java 8, while Ozone images have newer Java.
CI tweak for repro:
adoroszlai@33f7f4b
Failure:
https://github.com/adoroszlai/ozone/actions/runs/9792172547/job/27038142506#step:6:9
Exception can be seen in
log.htmlin the test artifact.Blog with great explanation of the problem and solution:
https://www.morling.dev/blog/bytebuffer-and-the-dreaded-nosuchmethoderror/
It can be fixed by setting
--releaseforjavac, viamaven.compiler.release. This is a new option for JDK 9+, so it must be done conditionally, in a profile.https://issues.apache.org/jira/browse/HDDS-11076
How was this patch tested?
Using the same CI repro with the fix:
https://github.com/adoroszlai/ozone/actions/runs/9792162687
Regular CI (for testing build with Java 8):
https://github.com/adoroszlai/ozone/actions/runs/9792724664