[2.x] Support JDK 25 JEP-512/JEP-445 Main class - #1601
Conversation
|
I copied your patch to the bridge in scala/scala (2.13.x) and tried a local build. It works when setting As mentioned by @xuwei-k, that's probably here: For main methods written in Java, sbt 1.11.6 finds zinc/internal/zinc-apiinfo/src/main/scala/sbt/internal/inc/ClassToAPI.scala Lines 172 to 181 in bcd91a1 |
|
Yea, for in-process run emulation, we need to change sbt itself. |
| } catch { | ||
| case _: Throwable => 0 | ||
| } | ||
| private[this] def isJava25Plus: Boolean = javaVersion >= 25 |
There was a problem hiding this comment.
I used scala.util.Properties.isJavaAtLeast(25) on scala/scala, but here it's probably safer not to rely on old (2.11) library code.
| _mainClasses += name | ||
| } | ||
| } else if ( | ||
| sym.isStatic && defType == DefinitionType.Module && definitions.hasJavaMainMethod(sym) |
There was a problem hiding this comment.
I consolidated the pre / post 25 checks a bit in scala/scala#11137
|
I also updated https://github.com/sbt/zinc/tree/develop/zinc/src/sbt-test/apiinfo/main-discovery in scala/scala#11137, that should apply here as well. |
399658e to
34158db
Compare
**Problem** sbt currently does not support JDK 25 Main class. JDK 25 supports: 1. non-public main method 2. doesn't need Array[String] arg 3. doesn't have to be a static method **Solution** This fixes the Main class detection for the reference compiler bridge, which is used for Scala 2.10 - 2.12, and Scala 2.13 until 2.13.11. Luckily, 2.13.11 is compatible with JDK 25. Co-authored-by: Lukas Rytz <lukas.rytz@gmail.com>
167ac8d to
1b69d99
Compare
|
Thanks! I've incorporated the scripted test change here. |
Ref sbt/sbt#7384
Problem
sbt currently does not support JDK 25 Main class. JDK 25 supports:
Solution
This fixes the Main class detection for the reference compiler bridge, which is used for Scala 2.10 - 2.12, and Scala 2.13 until 2.13.11. (Luckily, 2.13.11 is compatible with JDK 25, so we can use that to test 2.13)