Skip to content

Commit

Permalink
Run tests with jdk17 (#5598)
Browse files Browse the repository at this point in the history
  • Loading branch information
laurit committed Mar 17, 2022
1 parent 2ebe912 commit 45bd419
Show file tree
Hide file tree
Showing 19 changed files with 132 additions and 4 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ jobs:
test-java-version:
- 8
- 11
- 15
- 17
vm:
- hotspot
- openj9
- temurin
- adopt-openj9
fail-fast: false
steps:
- uses: actions/checkout@v3
Expand All @@ -37,7 +37,7 @@ jobs:
name: Set up JDK ${{ matrix.test-java-version }}-${{ matrix.vm }} for running tests
uses: actions/setup-java@v2
with:
distribution: adopt-${{ matrix.vm }}
distribution: ${{ matrix.vm }}
java-version: ${{ matrix.test-java-version }}

- name: Set up JDK 11 for running Gradle
Expand Down
13 changes: 13 additions & 0 deletions custom-checks/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ tasks {
compilerArgs.addAll(
listOf(
"--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
"--add-exports", "jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED",
"--add-exports", "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
"--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED"
)
Expand All @@ -42,6 +43,18 @@ tasks {
}
}

tasks.withType<Test>().configureEach {
// required on jdk17
jvmArgs("--add-opens=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED")
jvmArgs("--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED")
jvmArgs("--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED")
jvmArgs("--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED")
jvmArgs("--add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED")
jvmArgs("--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED")
jvmArgs("--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED")
jvmArgs("-XX:+IgnoreUnrecognizedVMOptions")
}

// Our conventions apply this project as a dependency in the errorprone configuration, which would cause
// a circular dependency if trying to compile this project with that still there. So we filter this
// project out.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,9 @@ dependencies {
testInstrumentation(project(":instrumentation:akka:akka-actor-2.5:javaagent"))
testInstrumentation(project(":instrumentation:akka:akka-actor-fork-join-2.5:javaagent"))
}

tasks.withType<Test>().configureEach {
// required on jdk17
jvmArgs("--add-exports=java.base/sun.security.util=ALL-UNNAMED")
jvmArgs("-XX:+IgnoreUnrecognizedVMOptions")
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,9 @@ dependencies {
compileOnly("com.google.auto.value:auto-value-annotations")
annotationProcessor("com.google.auto.value:auto-value")
}

tasks.withType<Test>().configureEach {
// required on jdk17
jvmArgs("--add-exports=java.base/sun.security.util=ALL-UNNAMED")
jvmArgs("-XX:+IgnoreUnrecognizedVMOptions")
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,9 @@ dependencies {
latestDepTestLibrary("org.springframework.data:spring-data-couchbase:3.+")
latestDepTestLibrary("com.couchbase.client:java-client:2.+")
}

tasks.withType<Test>().configureEach {
// required on jdk17
jvmArgs("--add-opens=java.base/java.lang.invoke=ALL-UNNAMED")
jvmArgs("-XX:+IgnoreUnrecognizedVMOptions")
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,7 @@ dependencies {
tasks.withType<Test>().configureEach {
// TODO run tests both with and without experimental span attributes
jvmArgs("-Dotel.instrumentation.elasticsearch.experimental-span-attributes=true")
// required on jdk17
jvmArgs("--add-opens=java.base/java.nio=ALL-UNNAMED")
jvmArgs("-XX:+IgnoreUnrecognizedVMOptions")
}
6 changes: 6 additions & 0 deletions instrumentation/guava-10.0/library/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ dependencies {
library("com.google.guava:guava:10.0")
implementation(project(":instrumentation-api-annotation-support"))
}

tasks.withType<Test>().configureEach {
// required on jdk17, uses spock Mock that needs access to jdk internals
jvmArgs("--add-opens=java.base/java.lang.invoke=ALL-UNNAMED")
jvmArgs("-XX:+IgnoreUnrecognizedVMOptions")
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ dependencies {
}

tasks.withType<Test>().configureEach {
// required on jdk17
jvmArgs("--add-opens=java.base/java.lang.invoke=ALL-UNNAMED")
jvmArgs("-XX:+IgnoreUnrecognizedVMOptions")

// TODO run tests both with and without experimental span attributes
jvmArgs("-Dotel.instrumentation.hibernate.experimental-span-attributes=true")
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ muzzle {
coreJdk()
}
}

tasks.withType<Test>().configureEach {
// required on jdk17
jvmArgs("--add-opens=java.base/sun.net.www.protocol.https=ALL-UNNAMED")
jvmArgs("-XX:+IgnoreUnrecognizedVMOptions")
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,12 @@ class AddUrlTest extends AgentInstrumentationSpecification {
TestURLClassLoader() {
super(new URL[0], (ClassLoader) null)
}

// silence CodeNarc. URLClassLoader#addURL is protected, this method is public
@SuppressWarnings("UnnecessaryOverridingMethod")
@Override
void addURL(URL url) {
super.addURL(url)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,9 @@ dependencies {

// Requires old Guava. Can't use enforcedPlatform since predates BOM
configurations.testRuntimeClasspath.resolutionStrategy.force("com.google.guava:guava:19.0")

tasks.withType<Test>().configureEach {
// required on jdk17
jvmArgs("--add-opens=java.base/java.net=ALL-UNNAMED")
jvmArgs("-XX:+IgnoreUnrecognizedVMOptions")
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,10 @@ dependencies {

latestDepTestLibrary("com.sun.xml.ws:jaxws-rt:2.+")
}

tasks.withType<Test>().configureEach {
// required on jdk17
jvmArgs("--add-exports=java.xml/com.sun.org.apache.xerces.internal.dom=ALL-UNNAMED")
jvmArgs("--add-exports=java.xml/com.sun.org.apache.xerces.internal.jaxp=ALL-UNNAMED")
jvmArgs("-XX:+IgnoreUnrecognizedVMOptions")
}
4 changes: 4 additions & 0 deletions instrumentation/jsp-2.3/javaagent/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ tasks.withType<Test>().configureEach {
jvmArgs("-Dorg.apache.catalina.startup.ContextConfig.jarsToSkip=*")
jvmArgs("-Dorg.apache.catalina.startup.TldConfig.jarsToSkip=*")

// required on jdk17
jvmArgs("--add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED")
jvmArgs("-XX:+IgnoreUnrecognizedVMOptions")

// TODO run tests both with and without experimental span attributes
jvmArgs("-Dotel.instrumentation.jsp.experimental-span-attributes=true")
}
6 changes: 6 additions & 0 deletions instrumentation/reactor/reactor-3.1/library/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,9 @@ dependencies {
// Looks like later versions on reactor need this dependency for some reason even though it is marked as optional.
latestDepTestLibrary("io.micrometer:micrometer-core:1.+")
}

tasks.withType<Test>().configureEach {
// required on jdk17, uses spock Mock that needs access to jdk internals
jvmArgs("--add-opens=java.base/java.lang.invoke=ALL-UNNAMED")
jvmArgs("-XX:+IgnoreUnrecognizedVMOptions")
}
2 changes: 2 additions & 0 deletions instrumentation/rmi/javaagent/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ dependencies {
annotationProcessor("com.google.auto.value:auto-value")

bootstrap(project(":instrumentation:rmi:bootstrap"))

implementation(project(":javaagent-tooling:javaagent-tooling-java9"))
}

// We cannot use "--release" javac option here because that will forbid importing "sun.rmi" package.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,19 @@
import io.opentelemetry.api.trace.Span;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.field.VirtualField;
import io.opentelemetry.javaagent.bootstrap.AgentClassLoader;
import io.opentelemetry.javaagent.bootstrap.InstrumentationHolder;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
import io.opentelemetry.javaagent.instrumentation.api.Java8BytecodeBridge;
import java.lang.instrument.Instrumentation;
import java.rmi.server.ObjID;
import java.util.Collections;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.dynamic.loading.ClassInjector;
import net.bytebuddy.matcher.ElementMatcher;
import net.bytebuddy.utility.JavaModule;
import sun.rmi.transport.Connection;

/**
Expand Down Expand Up @@ -58,6 +64,30 @@ public void transform(TypeTransformer transformer) {
.and(takesArgument(0, named("sun.rmi.transport.Connection")))
.and(takesArgument(1, named("java.rmi.server.ObjID"))),
getClass().getName() + "$StreamRemoteCallConstructorAdvice");

// expose sun.rmi.transport.StreamRemoteCall to helper classes
transformer.applyTransformer(
(builder, typeDescription, classLoader, module) -> {
if (JavaModule.isSupported()
&& classLoader == null
&& "sun.rmi.transport.StreamRemoteCall".equals(typeDescription.getName())
&& module != null) {
Instrumentation instrumentation = InstrumentationHolder.getInstrumentation();
ClassInjector.UsingInstrumentation.redefineModule(
instrumentation,
module,
Collections.emptySet(),
Collections.emptyMap(),
Collections.singletonMap(
"sun.rmi.transport",
// AgentClassLoader is in unnamed module of the bootstrap class loader which is
// where helper classes are also
Collections.singleton(JavaModule.ofType(AgentClassLoader.class))),
Collections.emptySet(),
Collections.emptyMap());
}
return builder;
});
}

@SuppressWarnings("unused")
Expand Down
4 changes: 4 additions & 0 deletions instrumentation/rxjava/rxjava-2.0/library/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@ dependencies {
}

tasks.withType<Test>().configureEach {
// required on jdk17, uses spock Mock that needs access to jdk internals
jvmArgs("--add-opens=java.base/java.lang.invoke=ALL-UNNAMED")
jvmArgs("-XX:+IgnoreUnrecognizedVMOptions")

jvmArgs("-Dio.opentelemetry.context.enableStrictContext=false")
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ dependencies {
library("io.reactivex.rxjava3:rxjava:3.0.12")
implementation(project(":instrumentation-api-annotation-support"))
}

tasks.withType<Test>().configureEach {
// required on jdk17, uses spock Mock that needs access to jdk internals
jvmArgs("--add-opens=java.base/java.lang.invoke=ALL-UNNAMED")
jvmArgs("-XX:+IgnoreUnrecognizedVMOptions")
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,9 @@ dependencies {

latestDepTestLibrary("org.hibernate:hibernate-entitymanager:5.+")
}

tasks.withType<Test>().configureEach {
// required on jdk17
jvmArgs("--add-opens=java.base/java.lang.invoke=ALL-UNNAMED")
jvmArgs("-XX:+IgnoreUnrecognizedVMOptions")
}

0 comments on commit 45bd419

Please sign in to comment.