[ https://issues.apache.org/jira/browse/FLINK-18455?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17148533#comment-17148533 ]
Niels Basjes commented on FLINK-18455: -------------------------------------- Looking at the actual Flink code I found that In a JDK 8 build both source and target are set to Java 8 [https://github.com/apache/flink/blob/d735d8cd8e5d9fae5322001099097581822453ae/pom.xml#L109] <java.version>1.8</java.version> [https://github.com/apache/flink/blob/d735d8cd8e5d9fae5322001099097581822453ae/pom.xml#L115] <maven.compiler.source>${java.version}</maven.compiler.source> <maven.compiler.target>${java.version}</maven.compiler.target> In a JDK 11 build a profile is activated that overrides it to Java 11 [https://github.com/apache/flink/blob/d735d8cd8e5d9fae5322001099097581822453ae/pom.xml#L938] <profile> <id>java11</id> <activation> <jdk>11</jdk> [https://github.com/apache/flink/blob/d735d8cd8e5d9fae5322001099097581822453ae/pom.xml#L1004] <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>11</source> <target>11</target> However I have Java 14 (and the 'java11' profile is only activated at the EXACT version of java 11) so it stays at source and target 1.8 but does not specify the "release 8" setting. ... which causes the problems I see. > 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 > Priority: Major > > 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: > {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] > - > [https://stackoverflow.com/questions/61267495/exception-in-thread-main-java-lang-nosuchmethoderror-java-nio-bytebuffer-flip] > > -As indicated in the mentioned Jetty ticket the solution is quite simple:- > {quote}-The solution is to cast the {{ByteBuffer}} to {{Buffer}} when calling > those methods:- > {code:java} > ((Buffer)byteBuffer).position(0);{code} > -- > {quote} > > > > -- This message was sent by Atlassian Jira (v8.3.4#803005)