[ 
https://issues.apache.org/jira/browse/FLINK-27549?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17959637#comment-17959637
 ] 

牛一凡 commented on FLINK-27549:
-----------------------------

Hello, I think this issue is very clear. 
In fact, when I modified the <target.java.version>1.8</target.java.version> in 
the pom.xml of the root directory of the flink project to 
<target.java.version>17</target.java.version>, and compiled the 1.18 project 
based on jdk17, I encountered this error: 

 
{code:java}
[ERROR] scalac error: 'jvm-17' is not a valid choice for '-target'
[INFO]   scalac -help  gives more information
[ERROR] scalac error: bad option: '-target:jvm-17'
[ERROR] Failed to execute goal 
net.alchim31.maven:scala-maven-plugin:3.2.2:compile (default-cli) on project 
flink-annotations: wrap: org.apache.commons.exec.ExecuteException: Process 
exited with an error: 1 (Exit value: 1) -> [Help 1]
{code}
!image-2025-06-11-11-17-54-715.png!

The compilation command I used was:
mvn clean install -Dmaven.compiler.source=17 -Dmaven.compiler.target=17 
-DskipTests -Dfast -Pskip-webui-build -T 1C
My JDK version is:
java version "17.0.15" 2025-04-15 LTS
Java(TM) SE Runtime Environment (build 17.0.15+9-LTS-241)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.15+9-LTS-241, mixed mode, sharing)

When I did not modify the pom.xml file, direct compilation based on the jdk17 
environment was feasible, but at this time the java class and scala class 
bytecode versions I got were both jdk8. I wonder if the flink project can now 
be compiled based on jdk17 and get the correct bytecode version? It seems that 
once I hardcode the jdk version, my compilation will fail.

> Inconsistent bytecode version when enable jdk11 or higher version
> -----------------------------------------------------------------
>
>                 Key: FLINK-27549
>                 URL: https://issues.apache.org/jira/browse/FLINK-27549
>             Project: Flink
>          Issue Type: Bug
>          Components: API / Scala
>    Affects Versions: 1.14.4, 1.15.0
>            Reporter: Ran Tao
>            Priority: Major
>         Attachments: image-2025-06-11-11-17-54-715.png, screenshot-1.png, 
> screenshot-2.png
>
>
> Current flink project build with jdk1.8 is ok.
> when enable jdk11, it has some scenarios.
> 1. Using jdk11 but source 1.8 target 1.8   it's ok.
> 2. Using jdk11 and with jdk11-target source 11 and target 11. build java ok. 
> But the generated bytecode version of scala class is already 52(jdk8).  We 
> can test with any of a scala class under jdk11 build result. e.g.
> {code:java}
> javap -verbose AggregateDataSet.class | grep major
> major version: 52
> {code}
> I have test many times and make conclusion that flink jdk11 now is not a 
> completed and pure jdk11 version because of inconsistent bytecode version 
> with java & scala. And it may cause some problems, for example:
> 1. inconsistent bytecode version between java & scala
> 2. Using reflection about class may generate some unkown errors
> 3. Runtime jdk11 environment can not optimize these lower bytecode.
> I have dipped into this problem and found out we must  upgrade scala to 
> 2.13(2.11 & 2.12 only support generate bytecode version <=1.8). the 2.13 can 
> support generate scala target 11 bytecode and higher and jdk8.
> We can see from scalac, the first is 2.12 the next is scala 2.13:
>  !screenshot-1.png! 
>  !screenshot-2.png! 
> By the way, even if scala-2.12 support generare 11 bytecode, current flink 
> build also fail. Because the config about scala-maven-plugin is error, the 
> correct format about jdk11 is target:11 not target:jvm-11, the latter format 
> only for <=1.8 with scala-2.11 and 2.12.
> {code:java}
> <plugin>
>                                       <groupId>net.alchim31.maven</groupId>
>                                       
> <artifactId>scala-maven-plugin</artifactId>
>                                       <version>3.2.2</version>
>                                       <configuration>
>                                               <args>
>                                                       <arg>-nobootcp</arg>
>                                                       
> <arg>-target:jvm-${target.java.version}</arg>
>                                               </args>
>                                               <jvmArgs>
>                                                       <arg>-Xss2m</arg>
>                                               </jvmArgs>
>                                       </configuration>
>                               </plugin>
> {code}
> I wonder current the community whether to support the completed jdk11 
> version? and  if not, at least we need to comment in pom or flink docs to let 
> users know about this problem?



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to