Niels Basjes created FLINK-18455:
------------------------------------

             Summary: Building with JDK 9+ leads to problems on JDK 8
                 Key: FLINK-18455
                 URL: https://issues.apache.org/jira/browse/FLINK-18455
             Project: Flink
          Issue Type: Bug
          Components: Build System
    Affects Versions: 1.10.1
            Reporter: Niels Basjes


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 the problem surfaces 
that the code crashes with the exception like this:
{code:java}
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/:?]

{code}
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:

- [https://issues.apache.org/jira/browse/MRESOLVER-67]
- [https://github.com/eclipse/jetty.project/issues/3244]
- [https://github.com/netty/netty/issues/9880]
- [https://github.com/apache/felix/pull/114]

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

bq. The solution is to cast the {{ByteBuffer}} to {{Buffer}} when calling those 
methods:  {code}((Buffer)byteBuffer).position(0);{code}
 

 

 

 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to