Skip to content

Commit

Permalink
Run tests on JDK 17
Browse files Browse the repository at this point in the history
  • Loading branch information
tgodzik committed Aug 31, 2021
1 parent 1c30a27 commit 4459624
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 19 deletions.
23 changes: 11 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,21 @@ jobs:
fail-fast: false
matrix:
os: [windows-latest, macOS-latest, ubuntu-latest]
java: [8, 11]
java: ['[email protected]']
shard: [1, 2]
exclude:
- os: windows-latest
java: 8
include:
- os: ubuntu-latest
java: '[email protected]'
shard: 1
- os: windows-latest
java: 8
- os: ubuntu-latest
java: '[email protected]'
shard: 2
- os: macOS-latest
java: 8
- os: ubuntu-latest
java: '17'
shard: 1
- os: macOS-latest
java: 8
- os: ubuntu-latest
java: '17'
shard: 2
include:
- os: ubuntu-latest
CACHE_PATH: ~/.cache/coursier/v1
- os: macOS-latest
Expand All @@ -38,7 +37,7 @@ jobs:
- uses: actions/checkout@v2
- uses: olafurpg/setup-scala@v12
with:
java-version: "adopt@1.${{ matrix.java }}"
java-version: ${{ matrix.java }}
- uses: coursier/[email protected]
- name: Run unit tests
run: |
Expand Down
1 change: 0 additions & 1 deletion bin/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ echo "-Xss4m" >> .jvmopts
echo "-Xmx1G" >> .jvmopts
echo "-XX:ReservedCodeCacheSize=1024m" >> .jvmopts
echo "-XX:+TieredCompilation" >> .jvmopts
echo "-XX:+CMSClassUnloadingEnabled" >> .jvmopts
echo "-Dfile.encoding=UTF-8" >> .jvmopts

sbt "$1"
Expand Down
8 changes: 4 additions & 4 deletions metals-docs/src/main/scala/docs/RequirementsModifier.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ class RequirementsModifier extends StringModifier {
s"""
|## Requirements
|
|**Java 8 or 11 provided by OpenJDK or Oracle**. Eclipse OpenJ9 is not
|**Java 8, 11, 17 provided by OpenJDK or Oracle**. Eclipse OpenJ9 is not
|supported, please make sure the `JAVA_HOME` environment variable
|points to a valid Java 8 or 11 installation.
|points to a valid Java 8, 11 or 17 installation.
|
|**macOS, Linux or Windows**. Metals is developed on macOS and every PR is
|tested on Ubuntu+Windows.
|**macOS, Linux or Windows**. Metals is developed on many operating systems and
|every PR is tested on Ubuntu, Windows and MacOS.
|
|**Scala 2.13, 2.12, 2.11 and Scala 3**. Metals supports these Scala versions:
|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,16 @@ object ClasspathLoader {
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
3 changes: 3 additions & 0 deletions tests/mtest/src/main/scala/tests/BaseSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ class BaseSuite extends munit.FunSuite with Assertions {
def isJava8: Boolean =
!Properties.isJavaAtLeast("9")

def isJava17: Boolean =
Properties.isJavaAtLeast("17")

def isWindows: Boolean =
Properties.isWin

Expand Down
3 changes: 2 additions & 1 deletion tests/unit/src/main/scala/tests/debug/BaseStepDapSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ abstract class BaseStepDapSuite(
main = "a.Main",
instrument = steps => {
val (javaLibFile, javaLibLine) =
if (isJava8) ("java/io/PrintStream.java", 805)
if (isJava17) ("java.base/java/io/PrintStream.java", 1027)
else if (isJava8) ("java/io/PrintStream.java", 805)
else ("java.base/java/io/PrintStream.java", 881)

steps
Expand Down

0 comments on commit 4459624

Please sign in to comment.