Matthew Ernst created FLINK-34658:
-------------------------------------

             Summary: Scala API unusable on Flink 1.18.1/Java 17 Docker image
                 Key: FLINK-34658
                 URL: https://issues.apache.org/jira/browse/FLINK-34658
             Project: Flink
          Issue Type: Bug
          Components: API / Scala
    Affects Versions: 1.18.1, 1.18.0
         Environment: This bug has been reproduced under macOS (Intel x64) and 
Linux (AMD 64) on a Flink cluster running in session mode.
            Reporter: Matthew Ernst


The Scala API should still work in Flink 1.18. The official Docker image for 
Flink 1.18.1 on Java 17 ("flink:1.18.1-scala_2.12-java17") causes jobs using 
the Scala API to immediately throw a ReflectiveOperationException. Jobs using 
the Scala API still work correctly on the Java 11 image 
("flink:1.18.1-scala_2.12-java11").

The problem happens because the flink-scala JAR file included in the image 
("flink-scala_2.12-1.18.1.jar") has been built with an old Scala compiler that 
has a [compatibility bug with Java 
17|https://github.com/scala/bug/issues/12419]. Rebuilding the flink-scala JAR 
file with the Scala compiler set to 2.12.15 or later fixes the bug. At my day 
job I cannot use Java 11 for a particular Flink job due to dependency on a Java 
library that uses [Java records|https://openjdk.org/jeps/395] (introduced in 
Java 16).

I have created a github repository with an example application and a longer 
description of the bug and how to fix it with a newer Scala compiler version: 
https://github.com/mattbernst/scala-java17-flink



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

Reply via email to