Scala Bytecode version

Hi Scala Users,

I am writing a scala code for spark structured streaming and have a dependency jar (java jar with bytecode 55) for kafka authentication. Scala code always produces a bytecode version of 52 and due to this I am always getting a version mismatch issue.

Components and versions involved:
Scala: 2.12
JVM: 11
Spark: 3.0.0
Spark Streaming 2.12: 3.0.0
Build tool: Maven

Can you please suggest to me what I should try to make the scala bytecode version to 55. I tried with scala3-compiler-3.3.0 but getting the same result. How to explicitly produce bytecode scala file same as Java. I saw some comments on github page for usage of options -target and -release but not sure how to use it.

Requesting to please respond.

also asked on the Scala Discord, with ensuing discussion: Discord

Scala 2.12 is limited to Java 8 (version 52) as explained here.

(A higher class file version permits stricter bytecode verification, which 2.12 code fails.)

Otherwise, you could specify -target 11, but you’d normally use -release 11 to both compile against JDK 11 API and output the corresponding class file (version 55).

I’m not sure what your underlying “version mismatch issue” is, so maybe there is a workaround for what you need to do.

oh jinx.