Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-18455

Building with JDK 9+ leads to problems on JDK 8

    XMLWordPrintableJSON

Details

    Description

      I was working on some changes in Flink and on my workstation I have also JDK 14 installed.

      When Flink is built using JDK > 8 and then run using JDK 8 the problem surfaces that the code crashes with the exception like this:

      java.lang.NoSuchMethodError: java.nio.ByteBuffer.position(I)Ljava/nio/ByteBuffer;
      	at org.apache.flink.core.memory.DataOutputSerializer.wrapAsByteBuffer(DataOutputSerializer.java:65) ~[classes/:?]
      	at org.apache.flink.runtime.io.network.api.serialization.SpanningRecordSerializer.<init>(SpanningRecordSerializer.java:50) ~[classes/:?]
      	at org.apache.flink.runtime.io.network.api.writer.RecordWriter.<init>(RecordWriter.java:98) ~[classes/:?]
      	at org.apache.flink.runtime.io.network.api.writer.ChannelSelectorRecordWriter.<init>(ChannelSelectorRecordWriter.java:50) ~[classes/:?]
      	at org.apache.flink.runtime.io.network.api.writer.RecordWriterBuilder.build(RecordWriterBuilder.java:53) ~[classes/:?]
      
      

      This is a problem in the way JDK 9+ generates the code that is incompatible with using the JDK 8 runtime, even if during the build it was indicated that JRE 8 would be the target.

      I have found several projects have ran into the exact same problem:

      As indicated in the mentioned Jetty ticket the solution is quite simple:

      The solution is to cast the ByteBuffer to Buffer when calling those methods:

      ((Buffer)byteBuffer).position(0);

       -- 

       

       

       

       

      Attachments

        Issue Links

          Activity

            People

              nielsbasjes Niels Basjes
              nielsbasjes Niels Basjes
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: