Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ import org.gradle.api.JavaVersion
import org.gradle.api.tasks.compile.AbstractCompile
import org.gradle.kotlin.dsl.extra

fun AbstractCompile.configureCompiler(
targetVersion: JavaVersion,
unsetReleaseFlagReason: String = "",
) {
(project.extra["configureCompiler"] as Closure<*>).call(this, targetVersion, unsetReleaseFlagReason)
}

fun AbstractCompile.configureCompiler(
toolchainVersion: Int,
targetVersion: JavaVersion,
Expand Down
2 changes: 1 addition & 1 deletion dd-java-agent/agent-bootstrap/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ sourceSets {

tasks.named("compileMain_java11Java", JavaCompile) {
// Do not lift this offset: these JFR bootstrap classes run on Java 8 JFR backports.
configureCompiler(it, 25, JavaVersion.VERSION_1_8, "Uses jdk.jfr module (Java 11+) at Java 8 bytecode")
configureCompiler(it, JavaVersion.VERSION_1_8, "Uses jdk.jfr module (Java 11+) at Java 8 bytecode")
}

dependencies {
Expand Down
4 changes: 2 additions & 2 deletions dd-java-agent/agent-installer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ dependencies {

tasks.named("compileMain_java11Java", JavaCompile) {
// Loaded reflectively only on Java 9+, so this can target Java 9 and restore --release.
configureCompiler(it, 25, JavaVersion.VERSION_1_8, "Uses the ClassFileTransformer Module overload (Java 9+) at Java 8 bytecode")
configureCompiler(it, JavaVersion.VERSION_1_8, "Uses the ClassFileTransformer Module overload (Java 9+) at Java 8 bytecode")
}

tasks.named("compileMain_java25Java", JavaCompile) {
// Loaded reflectively only on Java 22+, so this can target Java 22 and restore --release
// after confirming the implementation uses only the Java 22 FFM surface.
configureCompiler(it, 25, JavaVersion.VERSION_1_8, "Uses Foreign Function & Memory API (java.lang.foreign, Java 22+) at Java 8 bytecode")
configureCompiler(it, JavaVersion.VERSION_1_8, "Uses Foreign Function & Memory API (java.lang.foreign, Java 22+) at Java 8 bytecode")
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ excludedClassesCoverage += ['com.datadog.profiling.controller.jfr.JdkTypeIDs']
// Shared JFR implementation. The earliest Java version JFR is working on is Java 8
tasks.named("compileTestJava", JavaCompile) {
// These tests run only on Java 11+, so this can target Java 11 and restore --release.
configureCompiler(it, 25, JavaVersion.VERSION_1_8, "Uses jdk.jfr API (Java 11+) at Java 8 bytecode")
configureCompiler(it, JavaVersion.VERSION_1_8, "Uses jdk.jfr API (Java 11+) at Java 8 bytecode")
// Disable '-processing' because some annotations are not claimed.
// Disable '-options' because we are compiling for java8 without specifying bootstrap - intentionally.
// Disable '-path' because we do not have some of the paths seem to be missing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ tasks.named("compileJava", JavaCompile) {
tasks.named("compileMain_java11Java", JavaCompile) {
// Do not lift this to Java 11 while JFR-capable Java 9/10 distributions remain supported;
// --release 9 cannot expose the public JFR API introduced in Java 11.
configureCompiler(it, 25, JavaVersion.VERSION_1_9, "Uses public jdk.jfr APIs (Java 11+) at Java 9 bytecode")
configureCompiler(it, JavaVersion.VERSION_1_9, "Uses public jdk.jfr APIs (Java 11+) at Java 9 bytecode")
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ dependencies {
[JavaCompile, GroovyCompile].each {
tasks.withType(it).configureEach {
// Do not lift this offset: this controller runs on Java 8 distributions that backport JFR.
configureCompiler(it, 25, JavaVersion.VERSION_1_8, "Uses public jdk.jfr APIs (Java 11+) at Java 8 bytecode")
configureCompiler(it, JavaVersion.VERSION_1_8, "Uses public jdk.jfr APIs (Java 11+) at Java 8 bytecode")
// Disable '-processing' because some annotations are not claimed.
// Disable '-options' because we are compiling for java8 without specifying bootstrap - intentionally.
// Disable '-path' because we do not have some of the paths seem to be missing.
Expand Down
4 changes: 2 additions & 2 deletions dd-java-agent/agent-tooling/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ tasks.named("forbiddenApisJmh") { ignoreFailures = true }
tasks.named("compileTestJava") { dependsOn('generateTestClassNameTries') }

tasks.named("compileTest_java11Java") {
configureCompiler(it, 25, JavaVersion.VERSION_11)
configureCompiler(it, JavaVersion.VERSION_11)
}

tasks.named("compileTest_java21Java") {
// Relies on the daemon JDK (>= 18/19) so javac emits `invokeinterface` for `java.lang.Object`
// methods on an interface type. See https://bugs.openjdk.org/browse/JDK-8272715.
configureCompiler(it, 25, JavaVersion.VERSION_1_8)
configureCompiler(it, JavaVersion.VERSION_1_8)
}

tasks.named("jmh") {
Expand Down
2 changes: 1 addition & 1 deletion dd-java-agent/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def java6CompileTask = tasks.named("compileMain_java6Java") {
}

def java11CompileTask = tasks.named("compileMain_java11Java") {
configureCompiler(it, 25, JavaVersion.VERSION_11)
configureCompiler(it, JavaVersion.VERSION_11)
}

tasks.named("compileJava") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ repositories {
addTestSuiteForDir('latestDepTest', 'test')

tasks.named("compileMain_java11Java", JavaCompile) {
configureCompiler(it, 25, JavaVersion.VERSION_1_8)
configureCompiler(it, JavaVersion.VERSION_1_8)
}

["compileTestScala", "compileLatestDepTestScala"].each {
Expand All @@ -51,12 +51,12 @@ tasks.named("compileMain_java11Java", JavaCompile) {
}

tasks.named("compileTestGroovy", GroovyCompile) {
configureCompiler(it, 25, JavaVersion.VERSION_11)
configureCompiler(it, JavaVersion.VERSION_11)
classpath += files(tasks.named('compileTestScala').map { it.destinationDirectory })
}

tasks.named("compileLatestDepTestGroovy", GroovyCompile) {
configureCompiler(it, 25, JavaVersion.VERSION_11)
configureCompiler(it, JavaVersion.VERSION_11)
classpath += files(tasks.named('compileLatestDepTestScala').map { it.destinationDirectory })
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ tasks.named("jetty11Test", Test) {

["compileJetty11TestGroovy", "compileJetty11LatestDepTestGroovy"].each {
tasks.named(it, GroovyCompile) {
configureCompiler(it, 25, JavaVersion.VERSION_11)
configureCompiler(it, JavaVersion.VERSION_11)
}
}

Expand Down
4 changes: 2 additions & 2 deletions dd-java-agent/instrumentation/axis2-1.3/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ configurations.configureEach {

["compileLatestDepForkedTestGroovy", "compileLatestDepTestGroovy"].each {
tasks.named(it, GroovyCompile) {
configureCompiler(it, 25, JavaVersion.VERSION_17)
configureCompiler(it, JavaVersion.VERSION_17)
}
}

["compileLatestDepForkedTestJava", "compileLatestDepTestJava"].each {
tasks.named(it, JavaCompile) {
configureCompiler(it, 25, JavaVersion.VERSION_17)
configureCompiler(it, JavaVersion.VERSION_17)
}
}

Expand Down
4 changes: 2 additions & 2 deletions dd-java-agent/instrumentation/cxf-2.1/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ tasks.named("latestDepTest", Test) {
}

tasks.named("compileCxf3LatestDepTestGroovy", GroovyCompile) {
configureCompiler(it, 25, JavaVersion.VERSION_11)
configureCompiler(it, JavaVersion.VERSION_11)
}

tasks.named("latestDepTest", Test) {
javaLauncher = getJavaLauncherFor(17)
}

tasks.named("compileLatestDepTestGroovy", GroovyCompile) {
configureCompiler(it, 25, JavaVersion.VERSION_17)
configureCompiler(it, JavaVersion.VERSION_17)
}

tasks.named("cxf3LatestDepTest", Test) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ dependencies {
// Do not lift this offset: exception profiling runs on Java 8 distributions that backport JFR.
configureCompiler(
it,
25,
JavaVersion.VERSION_1_8,
"Uses public jdk.jfr APIs (Java 11+) at Java 8 bytecode"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ tracerJava {

["compileMain_java11Java", "compileTestJava"].each {
tasks.named(it, JavaCompile) {
configureCompiler(it, 25, JavaVersion.VERSION_11, "Uses --add-exports to access jdk.internal.vm.ci, which is incompatible with --release")
configureCompiler(it, JavaVersion.VERSION_11, "Uses --add-exports to access jdk.internal.vm.ci, which is incompatible with --release")
it.options.compilerArgs.addAll([
'-Xlint:all,-processing,-options,-path',
'--add-modules',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ dependencies {
"compileGraphql21LatestDepForkedTestGroovy"
].each {
tasks.named(it) {
configureCompiler(it, 25, JavaVersion.VERSION_11)
configureCompiler(it, JavaVersion.VERSION_11)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ tasks.named("latest5DepTest", Test) {
}

tasks.named("compileLatest5DepTestGroovy", GroovyCompile) {
configureCompiler(it, 25, JavaVersion.VERSION_21)
configureCompiler(it, JavaVersion.VERSION_21)
}

configurations.named("muleLatestDepTestRuntimeClasspath") {
Expand Down
2 changes: 1 addition & 1 deletion dd-java-agent/instrumentation/ignite-2.0/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ dependencies {

for (taskName in ['compileLatestDepTestGroovy', 'compileLatestDepForkedTestGroovy']) {
tasks.named(taskName, GroovyCompile) {
configureCompiler(it, 25, JavaVersion.VERSION_11)
configureCompiler(it, JavaVersion.VERSION_11)
}
}

Expand Down
4 changes: 2 additions & 2 deletions dd-java-agent/instrumentation/java/java-io-1.8/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ addTestSuiteForDir('java11Test', 'java11Test')
ext.java11TestMinJavaVersionForTests = JavaVersion.VERSION_11

tasks.named("compileJava11TestJava", JavaCompile) {
configureCompiler(it, 25, JavaVersion.VERSION_11)
configureCompiler(it, JavaVersion.VERSION_11)
}
tasks.named("compileJava11TestGroovy", GroovyCompile) {
configureCompiler(it, 25, JavaVersion.VERSION_11)
configureCompiler(it, JavaVersion.VERSION_11)
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ dependencies {
project.tasks.withType(AbstractCompile).configureEach {
switch (it.name) {
case 'compileCsiJava':
configureCompiler(it, 25, JavaVersion.VERSION_1_8)
configureCompiler(it, JavaVersion.VERSION_1_8)
break
default:
configureCompiler(it, 25, JavaVersion.VERSION_11)
configureCompiler(it, JavaVersion.VERSION_11)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ dependencies {
tasks.withType(AbstractCompile).configureEach {
switch (it.name) {
case 'compileCsiJava':
configureCompiler(it, 25, JavaVersion.VERSION_1_8)
configureCompiler(it, JavaVersion.VERSION_1_8)
break
default:
configureCompiler(it, 25, JavaVersion.VERSION_15)
configureCompiler(it, JavaVersion.VERSION_15)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ dependencies {
project.tasks.withType(AbstractCompile).configureEach {
switch (it.name) {
case 'compileCsiJava':
configureCompiler(it, 25, JavaVersion.VERSION_1_8)
configureCompiler(it, JavaVersion.VERSION_1_8)
break
default:
configureCompiler(it, 25, JavaVersion.VERSION_17)
configureCompiler(it, JavaVersion.VERSION_17)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ idea {

// Set test compile task to use JDK 21 to use the virtual threads API
tasks.named("compileTestJava", JavaCompile) {
configureCompiler(it, 25, JavaVersion.VERSION_21)
configureCompiler(it, JavaVersion.VERSION_21)
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ idea {

tasks.named("compileMain_java25Java", JavaCompile) {
// This advice is loaded only on Java 25, so a follow-up can target Java 25 and restore --release.
configureCompiler(it, 25, JavaVersion.VERSION_1_8, "Uses Foreign Function & Memory API (java.lang.foreign, Java 22+) at Java 8 bytecode")
configureCompiler(it, JavaVersion.VERSION_1_8, "Uses Foreign Function & Memory API (java.lang.foreign, Java 22+) at Java 8 bytecode")
}

// TODO Drop Groovy here
tasks.named("compileTestGroovy", GroovyCompile) {
// Groovy 3 cannot emit bytecode newer than Java 17. Keep the existing Java 8 bytecode while
// compiling against the Java 25 Foreign Function & Memory API used by this Java 25-only test.
configureCompiler(it, 25, JavaVersion.VERSION_1_8)
configureCompiler(it, JavaVersion.VERSION_1_8)
}
dependencies {
implementation project(':dd-java-agent:instrumentation:datadog:tracing:trace-annotation')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ project.tasks.withType(AbstractCompile).configureEach {
case 'compileJava':
// Do not lift this offset without splitting the API-specific classes: this instrumentation
// is discovered by the Java 8-compatible agent before its Java 9 applicability is known.
configureCompiler(it, 25, JavaVersion.VERSION_1_8, "Uses StringConcatFactory / java.lang.module APIs (Java 9+) at Java 8 bytecode")
configureCompiler(it, JavaVersion.VERSION_1_8, "Uses StringConcatFactory / java.lang.module APIs (Java 9+) at Java 8 bytecode")
break
default:
configureCompiler(it, 25, JavaVersion.VERSION_1_9)
configureCompiler(it, JavaVersion.VERSION_1_9)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ dependencies {
}

tasks.named("compileMain_java11Java", JavaCompile) {
configureCompiler(it, 25, JavaVersion.VERSION_11)
configureCompiler(it, JavaVersion.VERSION_11)
}

tasks.named("compileTestGroovy", GroovyCompile) {
configureCompiler(it, 25, JavaVersion.VERSION_11)
configureCompiler(it, JavaVersion.VERSION_11)
}

idea {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ testJvmConstraints {

["compileMain_java11Java", "compileTestJava"].each { name ->
tasks.named(name, JavaCompile) {
configureCompiler(it, 25, JavaVersion.VERSION_11)
configureCompiler(it, JavaVersion.VERSION_11)
it.options.compilerArgs.addAll(['-Xlint:all,-processing,-options,-path'])
}
}
Expand Down
4 changes: 2 additions & 2 deletions dd-java-agent/instrumentation/jersey/jersey-2.0/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ addTestSuiteForDir('jersey3JettyTest', 'jersey3JettyTest')
addTestSuiteForDir('latestDepTest', 'test')

tasks.named("compileJersey3JettyTestGroovy", GroovyCompile) {
configureCompiler(it, 25, JavaVersion.VERSION_11)
configureCompiler(it, JavaVersion.VERSION_11)
}

tasks.named("compileTestJava") {
configureCompiler(it, 25, JavaVersion.VERSION_11)
configureCompiler(it, JavaVersion.VERSION_11)
}

tasks.named("jersey3JettyTest", Test) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ addTestSuiteForDir('jetty11Test', 'test')
addTestSuiteForDir('jetty10LatestDepTest', 'test')

tasks.named("compileMain_java11Java", JavaCompile) {
configureCompiler(it, 25, JavaVersion.VERSION_1_8)
configureCompiler(it, JavaVersion.VERSION_1_8)
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ tracerJava {
addTestSuiteForDir('latestDepTest', 'test')

tasks.named("compileMain_java17Java", JavaCompile) {
configureCompiler(it, 25, JavaVersion.VERSION_17)
configureCompiler(it, JavaVersion.VERSION_17)
}

configurations.matching { it.name.startsWith('test') || it.name.startsWith('latestDepTest') }.configureEach {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ configurations.named('latestDepForkedTestRuntimeClasspath') {

tasks.named("compileMain_java11Java", JavaCompile) {
// Java 8 bytecode — override addSourceSetFor(11)'s Java 11 default
configureCompiler(it, 25, JavaVersion.VERSION_1_8)
configureCompiler(it, JavaVersion.VERSION_1_8)
}

idea {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ dependencies {

tasks.named("compileMain_java11Java", JavaCompile) {
// Java 8 bytecode — override addSourceSetFor(11)'s Java 11 default
configureCompiler(it, 25, JavaVersion.VERSION_1_8)
configureCompiler(it, JavaVersion.VERSION_1_8)
}

tasks.withType(Test).configureEach {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ addTestSuiteExtendingForDir('ee10LatestDepForkedTest', 'ee10LatestDepTest', 'tes
["compileMain_java17Java", "compileTestJava"].each {
tasks.named(it, JavaCompile) {
// Jetty 12 requires Java 17, so these classes can target Java 17 and restore --release.
configureCompiler(it, 25, JavaVersion.VERSION_1_8, "Uses java.lang.Record (Java 16+) at Java 8 bytecode")
configureCompiler(it, JavaVersion.VERSION_1_8, "Uses java.lang.Record (Java 16+) at Java 8 bytecode")
}
}
["ee8LatestDepTest", "ee9LatestDepTest", "ee10LatestDepTest"].each {
Expand All @@ -48,7 +48,7 @@ addTestSuiteExtendingForDir('ee10LatestDepForkedTest', 'ee10LatestDepTest', 'tes
}

tasks.withType(GroovyCompile).configureEach {
configureCompiler(it, 25, JavaVersion.VERSION_17)
configureCompiler(it, JavaVersion.VERSION_17)
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ repositories {
}

tasks.named("compileTestGroovy", GroovyCompile) {
configureCompiler(it, 25, JavaVersion.VERSION_17)
configureCompiler(it, JavaVersion.VERSION_17)
}

dependencies {
Expand Down
Loading
Loading