Skip to content

Commit

Permalink
Open java.base/java.lang for ALL-UNNAMED
Browse files Browse the repository at this point in the history
Since jacoco 0.8.9 it does not open the java.lang package anymore,
so we need to do that on our own.

See "Agent should not open java.lang package to unnamed module of the application class loader"

jacoco/jacoco#1334
  • Loading branch information
AndreasTu committed Aug 9, 2023
1 parent 298eace commit f21688c
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[versions]
groovy2 = '2.5.19'
groovy3 = '3.0.13'
groovy3 = '3.0.17'
groovy4 = '4.0.6'
jacoco = '0.8.10'

Expand Down
9 changes: 9 additions & 0 deletions spock-guice/guice.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,12 @@ tasks.named("jar", Jar) {
)
}
}

tasks.named("test", Test).configure {
if (rootProject.ext.javaVersion >= 17) {
jvmArgs(
//Guice Framework requires access to java.lang.ClassLoader.defineClass() from com.google.inject.internal.cglib.core.$ReflectUtils
"--add-opens=java.base/java.lang=ALL-UNNAMED"
)
}
}
18 changes: 18 additions & 0 deletions spock-specs/mock-integration/mock-integration.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,29 @@ codeGenerationLibraries.each { key, config ->
tasks.register("test${key.capitalize()}WithoutObjenesis", Test) {
systemProperty("org.spockframework.mock.testType", "${key.toLowerCase()} - objenesis")
classpath += config

if (key == "cglib") {
if (rootProject.ext.javaVersion >= 17) {
jvmArgs(
//cglib requires access to java.lang.ClassLoader.defineClass() from net.sf.cglib.core.ReflectUtils
"--add-opens=java.base/java.lang=ALL-UNNAMED"
)
}
}
}
tasks.register("test${key.capitalize()}WithObjenesis", Test) {
systemProperty("org.spockframework.mock.testType", "${key.toLowerCase()} + objenesis")
classpath += config
classpath += configurations.objenesis

if (key == "cglib") {
if (rootProject.ext.javaVersion >= 17) {
jvmArgs(
//cglib requires access to java.lang.ClassLoader.defineClass() from net.sf.cglib.core.ReflectUtils
"--add-opens=java.base/java.lang=ALL-UNNAMED"
)
}
}
}
}

Expand Down
10 changes: 10 additions & 0 deletions spock-spring/spring3-test/spring3-test.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,13 @@ configurations.all {
}
}
}


tasks.named("test", Test).configure {
if (rootProject.ext.javaVersion >= 17) {
jvmArgs(
//Spring Framework requires access to java.lang.ClassLoader.defineClass() from org.springframework.cglib.core.ReflectUtils
"--add-opens=java.base/java.lang=ALL-UNNAMED"
)
}
}
9 changes: 9 additions & 0 deletions spock-spring/spring5-test/spring5-test.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,12 @@ configurations.all {
}
}
}

tasks.named("test", Test).configure {
if (rootProject.ext.javaVersion >= 17) {
jvmArgs(
//Spring Framework requires access to java.lang.ClassLoader.defineClass() from org.springframework.cglib.core.ReflectUtils
"--add-opens=java.base/java.lang=ALL-UNNAMED"
)
}
}

0 comments on commit f21688c

Please sign in to comment.