Skip to content

Commit

Permalink
add jdk 17 ci and fix its support (#1502)
Browse files Browse the repository at this point in the history
  • Loading branch information
mlachkar authored Nov 26, 2021
1 parent 3fe23a5 commit 9f8f881
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ jobs:
java-version: adopt@1.11
- run: sbt ci-213

jdk17_213:
name: JDK117/scala_2.13 tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: olafurpg/setup-scala@v13
with:
java-version: 17
- run: sbt ci-213

windows_213:
name: Windows/scala_2.13 tests
runs-on: windows-latest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,14 @@ object ClasspathOps {
val unsafe = field.get(null).asInstanceOf[Unsafe]

// jdk.internal.loader.ClassLoaders.AppClassLoader.ucp
val ucpField = classLoader.getClass().getDeclaredField("ucp")
val ucpField = {
if (
System.getProperty("java.version").split("(\\.|-)")(0).toInt >= 16
) {
// the `ucp` field is not in `AppClassLoader` anymore, but in `BuiltinClassLoader`
classLoader.getClass().getSuperclass()
} else classLoader.getClass()
}.getDeclaredField("ucp")
val ucpFieldOffset: Long = unsafe.objectFieldOffset(ucpField)
val ucpObject = unsafe.getObject(classLoader, ucpFieldOffset)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,13 @@ class ScalafixSuite extends AnyFunSuite {

// 2.11(.12) triggers `java.lang.NoClassDefFoundError: javax/tools/DiagnosticListener` on Java11.
// See https://github.com/scala/bug/issues/10603.
val isJava11: Boolean = Option(System.getProperty("java.version"))
.getOrElse("")
.startsWith("11")
val javaVersionOpt: Option[String] = Option(
System.getProperty("java.version")
)
val isJava11: Boolean = javaVersionOpt.getOrElse("").startsWith("11")
val isJava17: Boolean = javaVersionOpt.getOrElse("").startsWith("17")
val scalaBinaryVersionsToRun: Set[String] =
if (isJava11) supportedScalaBinaryVersions - "2.11"
if (isJava11 || isJava17) supportedScalaBinaryVersions - "2.11"
else supportedScalaBinaryVersions

scalaBinaryVersionsToRun.map { scalaBinaryVersion =>
Expand Down

0 comments on commit 9f8f881

Please sign in to comment.