Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
c3b84a8
Set default java toolchain to 8
smola May 23, 2025
a1ac2bb
Set toolchain early
smola May 26, 2025
1dfab6e
Set JAVA_HOME for smoke test builds
smola May 23, 2025
79bc62d
Do not set compiler release by default (remove skipSettingCompilerRel…
smola May 23, 2025
994187b
build: Run instrument plugin with toolchain
smola May 24, 2025
578e1f3
build: Check version in CI
bric3 Sep 12, 2025
4c849fc
fix: call-instrumentation-site test due to the appearance of Sequence…
bric3 Sep 12, 2025
592393c
chore: Explicit setup of the compiler
bric3 Sep 18, 2025
53e0c2f
refactor: setJavaVersion becomes configureCompiler, handles release/s…
bric3 Sep 19, 2025
f8bb374
fix: project.afterEvaluate messing with setting up "testJvm"
bric3 Sep 26, 2025
951ead6
fix: duplicated task config
bric3 Sep 26, 2025
3de0687
fix: Failing :dd-java-agent:agent-tooling tests
bric3 Sep 29, 2025
243fb66
fix: Failing :dd-java-agent:agent-ci-visibility
bric3 Sep 29, 2025
6189e6d
fix: Fix Groovy delegation that was adding interfaces to object deleg…
bric3 Sep 29, 2025
11f3a9e
fix: Fix muzzle detected that compiler generated an invokeinterface f…
bric3 Sep 29, 2025
1662e97
fix: Fix jdbc tests because `java.sql.Connection` introduced methods …
bric3 Sep 29, 2025
44c80c1
fix: dd-smoke-tests needs to use Java 8
bric3 Sep 30, 2025
a42c443
chore: Make spotless happy
bric3 Sep 30, 2025
5a58934
fix: iast-agent was not using configureCompiler
bric3 Sep 30, 2025
7978d03
fix: Make resilience4j modules use configureCompiler
bric3 Sep 30, 2025
710175a
fix: Replace Groovy's getProperty by Project.findProperty
bric3 Sep 30, 2025
30b5e53
fix: vertx-web-5.0 now uses configureCompiler
bric3 Sep 30, 2025
6c7855e
fix: smoke appsec/springboot-graphql needs to compile to Java 1.8
bric3 Oct 1, 2025
6560061
chore: fail early when testJvm is blank
bric3 Oct 1, 2025
ad863dc
fix: Enforce ByteCode 1.8 on some jetty projects
bric3 Oct 1, 2025
2bc40c3
style: Typo
bric3 Oct 2, 2025
e8ab4c6
Revert "fix: Fix muzzle detected that compiler generated an invokeint…
bric3 Oct 2, 2025
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
9 changes: 8 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ build:
DEPENDENCY_CACHE_POLICY: pull
script:
- if [ $CI_PIPELINE_SOURCE == "schedule" ] ; then ./gradlew resolveAndLockAll --write-locks $GRADLE_ARGS; fi
- ./gradlew --version
- ./gradlew clean :dd-java-agent:shadowJar :dd-trace-api:jar :dd-trace-ot:shadowJar -PskipTests $GRADLE_ARGS
- echo UPSTREAM_TRACER_VERSION=$(java -jar workspace/dd-java-agent/build/libs/*.jar) >> upstream.env
- echo "BUILD_JOB_NAME=$CI_JOB_NAME" >> build.env
Expand Down Expand Up @@ -296,6 +297,7 @@ build_tests:

script:
- *gitlab_base_ref_params
- ./gradlew --version
- ./gradlew clean $GRADLE_TARGET $GRADLE_PARAMS -PskipTests $GRADLE_ARGS

populate_dep_cache:
Expand Down Expand Up @@ -362,7 +364,7 @@ spotless:
stage: tests
needs: []
script:
- export JAVA_HOME=$JAVA_11_HOME
- ./gradlew --version
- ./gradlew spotlessCheck $GRADLE_ARGS

test_published_artifacts:
Expand All @@ -381,6 +383,7 @@ test_published_artifacts:
- ./gradlew publishToMavenLocal $GRADLE_ARGS
- cd test-published-dependencies
- export GRADLE_OPTS="-Dorg.gradle.jvmargs='-Xmx1G -Xms1G -XX:ErrorFile=/tmp/hs_err_pid%p.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp'"
- ./gradlew --version
- ./gradlew check --info $GRADLE_ARGS
after_script:
- *cgroup_info
Expand All @@ -401,6 +404,7 @@ test_published_artifacts:
CACHE_TYPE: lib
script:
- *gitlab_base_ref_params
- ./gradlew --version
- ./gradlew $GRADLE_TARGET $GRADLE_PARAMS -PskipTests -PrunBuildSrcTests -PskipSpotless -PtaskPartitionCount=$NORMALIZED_NODE_TOTAL -PtaskPartition=$NORMALIZED_NODE_INDEX $GRADLE_ARGS
after_script:
- *cgroup_info
Expand Down Expand Up @@ -461,6 +465,7 @@ muzzle:
CACHE_TYPE: inst
script:
- export SKIP_BUILDSCAN="true"
- ./gradlew --version
- ./gradlew :runMuzzle -PtaskPartitionCount=$NORMALIZED_NODE_TOTAL -PtaskPartition=$NORMALIZED_NODE_INDEX $GRADLE_ARGS
after_script:
- *cgroup_info
Expand All @@ -482,6 +487,7 @@ muzzle-dep-report:
CACHE_TYPE: inst
script:
- export SKIP_BUILDSCAN="true"
- ./gradlew --version
- ./gradlew generateMuzzleReport muzzleInstrumentationReport $GRADLE_ARGS
after_script:
- *cgroup_info
Expand Down Expand Up @@ -541,6 +547,7 @@ muzzle-dep-report:
fi
- *prepare_test_env
- export GRADLE_OPTS="-Dorg.gradle.jvmargs='-Xms$GRADLE_MEM -Xmx$GRADLE_MEM $PROFILER_COMMAND -XX:ErrorFile=/tmp/hs_err_pid%p.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp' -Ddatadog.forkedMaxHeapSize=1024M -Ddatadog.forkedMinHeapSize=128M"
- ./gradlew --version
- ./gradlew $GRADLE_TARGET $GRADLE_PARAMS -PtestJvm=$testJvm -PtaskPartitionCount=$NORMALIZED_NODE_TOTAL -PtaskPartition=$NORMALIZED_NODE_INDEX $GRADLE_ARGS --continue || $CONTINUE_ON_FAILURE
after_script:
- *restore_pretest_env
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ class AssertBuilder<C extends CallSiteAssert> {
return [null, null]
}
final isEnabled = type.getMethodsByName('isEnabled').first()
final returnStatement = isEnabled.body.get().statements.first.get().asReturnStmt()
// JavaParser's NodeList has method getFirst() returning an Optional, however with Java 21's
// SequencedCollection, Groovy picks the getFirst() that returns the object itself.
// Using `first()` rather than `first` picks the groovy method instead, fixing the situation.
final returnStatement = isEnabled.body.get().statements.first().asReturnStmt()
final enabledMethodCall = returnStatement.expression.get().asMethodCallExpr()
final enabled = resolveMethod(enabledMethodCall)
final enabledArgs = enabledMethodCall.getArguments().collect { it.asStringLiteralExpr().asString() }.toSet()
Expand Down
19 changes: 9 additions & 10 deletions buildSrc/src/main/groovy/InstrumentPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,16 @@ abstract class InstrumentTask extends DefaultTask {
}

private workQueue() {
if (this.javaVersion) {
def javaLauncher = this.javaToolchainService.launcherFor { spec ->
spec.languageVersion.set(JavaLanguageVersion.of(this.javaVersion))
}.get()
return this.workerExecutor.processIsolation { spec ->
spec.forkOptions { fork ->
fork.executable = javaLauncher.executablePath
}
if (!this.javaVersion) {
this.javaVersion = "8"
}
def javaLauncher = this.javaToolchainService.launcherFor { spec ->
spec.languageVersion.set(JavaLanguageVersion.of(this.javaVersion))
}.get()
return this.workerExecutor.processIsolation { spec ->
spec.forkOptions { fork ->
fork.executable = javaLauncher.executablePath
}
} else {
return this.workerExecutor.noIsolation()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,17 @@ abstract class MuzzleTask @Inject constructor(
val javaLauncher = javaToolchainService.launcherFor {
languageVersion.set(JavaLanguageVersion.of(muzzleDirective.javaVersion!!))
}.get()
// Note process isolation leaks gradle dependencies to the child process
// and may need additional code on muzzle plugin to filter those out
// See https://github.com/gradle/gradle/issues/33987
workerExecutor.processIsolation {
forkOptions {
executable(javaLauncher.executablePath)
}
}
} else {
// noIsolation worker is OK for muzzle tasks as their checks will inspect classes outline
// and should not be impacted by the actual running JDK.
workerExecutor.noIsolation()
}
workQueue.submit(MuzzleAction::class.java) {
Expand Down
34 changes: 17 additions & 17 deletions dd-java-agent/agent-bootstrap/build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import de.thetaphi.forbiddenapis.gradle.CheckForbiddenApis

// The shadowJar of this project will be injected into the JVM's bootstrap classloader
plugins {
id 'com.gradleup.shadow'
id 'me.champeau.jmh'
}

ext {
// need access to sun.* packages
skipSettingCompilerRelease = true
}

apply from: "$rootDir/gradle/java.gradle"
apply plugin: "idea"

tasks.named("compileJava", JavaCompile).configure {
configureCompiler(it, 8, JavaVersion.VERSION_1_8, "Need access to sun.* packages")
}

// FIXME: Improve test coverage.
minimumBranchCoverage = 0.0
minimumInstructionCoverage = 0.0
Expand All @@ -37,10 +38,8 @@ sourceSets {
}
}

compileMain_java11Java.configure {
setJavaVersion(it, 11)
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
tasks.named("compileMain_java11Java", JavaCompile) {
configureCompiler(it, 11, JavaVersion.VERSION_1_8)
}

dependencies {
Expand All @@ -52,7 +51,7 @@ tasks.named("jar", Jar) {
from sourceSets.main_java11.output
}

tasks.named("forbiddenApisMain_java11") {
tasks.named("forbiddenApisMain_java11", CheckForbiddenApis) {
failOnMissingClasses = false
}

Expand All @@ -63,14 +62,15 @@ idea {
}

jmh {
jmhVersion = libs.versions.jmh.get()
jmhVersion = libs.versions.jmh
duplicateClassesStrategy = DuplicatesStrategy.EXCLUDE
}

project.afterEvaluate {
tasks.withType(Test).configureEach {
if (javaLauncher.get().metadata.languageVersion.asInt() >= 16) {
jvmArgs += ['--add-opens', 'java.base/java.net=ALL-UNNAMED'] // for HostNameResolverForkedTest
}
}
tasks.withType(Test).configureEach {
configureJvmArgs(
it,
JavaVersion.VERSION_16,
['--add-opens', 'java.base/java.net=ALL-UNNAMED'] // for HostNameResolverForkedTest
)

}
4 changes: 1 addition & 3 deletions dd-java-agent/agent-builder/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ sourceSets {
}

tasks.named("compileMain_java11Java", JavaCompile) {
setJavaVersion(it, 11)
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
configureCompiler(it, 11, JavaVersion.VERSION_1_8)
}

dependencies {
Expand Down
10 changes: 10 additions & 0 deletions dd-java-agent/agent-ci-visibility/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,13 @@ tasks.named("shadowJar", ShadowJar) {
tasks.named("jar", Jar) {
archiveClassifier = 'unbundled'
}

tasks.named("compileTestGroovy") {
configureCompiler(
it,
8,
JavaVersion.VERSION_1_8,
"Groovy generates synthetic accessors methods from superclass, we don't want that for `MisbehavingClassLoader`," +
" otherwise anonymous class has one `loadClass` accessor's signature has `java.lang.Module`"
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,11 @@ apply from: "$rootDir/gradle/java.gradle"
dependencies {
implementation group: 'org.scala-lang', name: 'scala-compiler', version: '2.13.3'
}

tasks.withType(ScalaCompile).configureEach {
// Despite the compatibility matrix, scala compiler doesn't properly
// get the right compiler flags with JDK11 toolchain. Using 8 works.
// * https://docs.scala-lang.org/overviews/jdk-compatibility/overview.html
// * https://github.com/gradle/gradle/issues/19456
configureCompiler(it, 8)
}
11 changes: 1 addition & 10 deletions dd-java-agent/agent-iast/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,8 @@ plugins {
apply from: "$rootDir/gradle/java.gradle"
apply from: "$rootDir/gradle/version.gradle"

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(11))
}
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

tasks.withType(AbstractCompile).configureEach {
// ensure no APIs beyond JDK8 are used
options.release = 8
configureCompiler(it, 11, JavaVersion.VERSION_1_8, "Ensure no APIs beyond JDK8 are used")
}

// First version with Mac M1 support
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ ext {
// By default tests with be compiled for `minJavaVersionForTests` version,
// but in this case we would like to avoid this since we would like to run with ZULU8
skipSettingTestJavaVersion = true
// need access to jdk.jfr package
skipSettingCompilerRelease = true
excludeJdk = ['SEMERU11', 'SEMERU17']
}

Expand Down Expand Up @@ -39,16 +37,12 @@ dependencies {
* We specify source/target as Java8 to get code that is loadable on Java8 - JFR defs are Java8 compatible.
* We force IDEA to treat this as Java11 project with 'idea' plugin below.
*/
[JavaCompile, GroovyCompile].each {
tasks.withType(it).configureEach {
setJavaVersion(it, 11)
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
// 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.
options.compilerArgs.addAll(['-Xlint:all,-processing,-options,-path'/*, '-Werror'*/])
}
tasks.withType(AbstractCompile).configureEach {
configureCompiler(it, 11, JavaVersion.VERSION_1_8)
// 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.
options.compilerArgs.addAll(['-Xlint:all,-processing,-options,-path'/*, '-Werror'*/])
}

tasks.named("forbiddenApisMain") {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import de.thetaphi.forbiddenapis.gradle.CheckForbiddenApis

// Set properties before any plugins get loaded
ext {
// the tests need Java 11 because the JFR writer got compiled with a version
// of ByteBuffer.position(int) which is binary incompatible with Java 8 ¯\_(ツ)_/¯
minJavaVersionForTests = JavaVersion.VERSION_11

// need access to jdk.jfr package
skipSettingCompilerRelease = true

excludeJdk = ['SEMERU11', 'SEMERU17']
}

Expand All @@ -31,19 +30,16 @@ 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) {
setJavaVersion(it, 11)
// tests should be compiled in Java 8 compatible way
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
configureCompiler(it, 11, JavaVersion.VERSION_1_8)
// 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.
options.compilerArgs.addAll(['-Xlint:all,-processing,-options,-path'/*, '-Werror'*/])
}

tasks.named("forbiddenApisMain") {
tasks.named("forbiddenApisMain", CheckForbiddenApis) {
failOnMissingClasses = false
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import de.thetaphi.forbiddenapis.gradle.CheckForbiddenApis

// Set properties before any plugins get loaded
ext {
minJavaVersionForTests = JavaVersion.VERSION_1_8

// need access to jdk.jfr package
skipSettingCompilerRelease = true
}

apply from: "$rootDir/gradle/java.gradle"
Expand All @@ -16,10 +15,12 @@ sourceSets {
}
}

compileMain_java11Java.configure {
setJavaVersion(it, 11)
sourceCompatibility = JavaVersion.VERSION_1_9
targetCompatibility = JavaVersion.VERSION_1_9
tasks.named("compileJava", JavaCompile) {
configureCompiler(it, 11, JavaVersion.VERSION_1_8, "Need access to jdk.jfr.internal.*")
}

tasks.named("compileMain_java11Java", JavaCompile) {
configureCompiler(it, 11, JavaVersion.VERSION_1_9)
}

dependencies {
Expand All @@ -40,12 +41,12 @@ excludedClassesCoverage += [
'com.datadog.profiling.controller.jfr.SimpleJFRAccess*'
]

jar {
tasks.named("jar", Jar) {
from sourceSets.main_java11.output
}

forbiddenApisMain {
failOnMissingClasses = false
tasks.named("forbiddenApisMain", CheckForbiddenApis) {
it.failOnMissingClasses = false
}

idea {
Expand All @@ -54,12 +55,12 @@ idea {
}
}

project.afterEvaluate {
tasks.withType(Test).configureEach {
if (javaLauncher.get().metadata.languageVersion.asInt() >= 9) {
jvmArgs += [
'--add-opens',
'jdk.jfr/jdk.jfr.internal=ALL-UNNAMED'] // JPMSJFRAccess needs access to jdk.jfr.internal package
}
}
tasks.withType(Test).configureEach {
configureJvmArgs(
it,
JavaVersion.VERSION_1_9,
[
'--add-opens',
'jdk.jfr/jdk.jfr.internal=ALL-UNNAMED'] // JPMSJFRAccess needs access to jdk.jfr.internal package
)
}
Loading