Skip to content

Conversation

@adoroszlai
Copy link
Contributor

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:

NoSuchMethodError: java.nio.ByteBuffer.position(I)Ljava/nio/ByteBuffer;
	at org.apache.hadoop.ozone.common.ChunkBufferImplWithByteBuffer.duplicate(ChunkBufferImplWithByteBuffer.java:111)

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.html in 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 --release for javac, via maven.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

@adoroszlai adoroszlai added the build Pull request that modifies the build process label Jul 4, 2024
@adoroszlai adoroszlai self-assigned this Jul 4, 2024
@adoroszlai adoroszlai requested a review from szetszwo July 7, 2024 17:57
Copy link
Contributor

@szetszwo szetszwo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 the change looks good.

@adoroszlai adoroszlai merged commit 8f610da into apache:master Jul 8, 2024
@adoroszlai adoroszlai deleted the HDDS-11076 branch July 8, 2024 06:23
@adoroszlai
Copy link
Contributor Author

Thanks @szetszwo for the review.

adoroszlai added a commit to adoroszlai/ozone that referenced this pull request Jul 29, 2024
…with Java 9+, running with Java 8 (apache#6897)"

This reverts commit 8f610da.
kerneltime pushed a commit that referenced this pull request Jul 29, 2024
* Revert "HDDS-11076. NoSuchMethodError: ByteBuffer.position compiling with Java 9+, running with Java 8 (#6897)"

This reverts commit 8f610da.

* Revert "HDDS-11078. Remove usage of sun.misc.Signal (#6876)"

This reverts commit 3f14219.
adoroszlai added a commit that referenced this pull request Aug 1, 2024
…a 9+, running with Java 8 (#6897)

(cherry picked from commit 8f610da)
devabhishekpal pushed a commit to devabhishekpal/ozone that referenced this pull request Aug 8, 2024
…a 9+, running with Java 8 (apache#6897)

(cherry picked from commit 8f610da)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Pull request that modifies the build process

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants