Uploaded image for project: 'Apache Ozone'
  1. Apache Ozone
  2. HDDS-8246 Java 11/17 Support and Testing
  3. HDDS-11076

NoSuchMethodError: ByteBuffer.position compiling with Java 9+, running with Java 8

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 2.0.0
    • build

    Description

      Building Ozone with Java 9+ (but with target=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)
      

      Explanation:
      https://www.morling.dev/blog/bytebuffer-and-the-dreaded-nosuchmethoderror/

      Can be fixed by setting --release for javac (only for JDK 9+, since it's a new param), via maven.compiler.release.

      When using --release, access to Sun internal API is not allowed: https://bugs.openjdk.org/browse/JDK-8206937 Therefore this fix requires HDDS-11078.

      Attachments

        Issue Links

          Activity

            People

              adoroszlai Attila Doroszlai
              adoroszlai Attila Doroszlai
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: