Skip to content

Commit 9bf338b

Browse files
Disable invokedynamic bytecode for legacy Gradle instrumentation (#11618)
fix: disable invokedynamic compilation for legacy gradle instrumentation nit: comment test: bump oldest test case to 4.x Merge branch 'master' into daniel.mohedano/fix-gradle-legacy-compilation Co-authored-by: daniel.mohedano <daniel.mohedano@datadoghq.com>
1 parent c81bb4e commit 9bf338b

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

dd-java-agent/instrumentation/gradle/gradle-3.0/build.gradle

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,14 @@ repositories {
99
dependencies {
1010
compileOnly gradleApi()
1111
}
12+
13+
// This module's Groovy classes are loaded into the user's Gradle daemon, which might bundle Groovy <3.0 (Gradle <7.x).
14+
// Groovy 4 (bundled by the build's Gradle 9+) compiles invokedynamic by default, binding dynamic calls to
15+
// org.codehaus.groovy.vmplugin.v8.IndyInterface — a class that only exists from Groovy
16+
// 3.0 onwards. Under Groovy <3.0 that bootstrap target is missing, so the classes fail
17+
// to link and CI Visibility never instruments the build. Force classic call-site
18+
// dispatch so the emitted bytecode links on older daemons regardless of the build's
19+
// bundled Groovy version.
20+
tasks.withType(GroovyCompile).configureEach {
21+
groovyOptions.optimizationOptions.indy = false
22+
}

dd-smoke-tests/gradle/src/test/java/datadog/smoketest/GradleDaemonSmokeTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void stopGradleTestKitDaemons() {
6363

6464
@TableTest({
6565
"scenario | gradleVersion | projectName | successExpected | expectedTraces | expectedCoverages",
66-
"succeed-old-gradle-3.5 | 3.5 | test-succeed-old-gradle | true | 5 | 1 ",
66+
"succeed-old-gradle-4.10 | 4.10 | test-succeed-old-gradle | true | 5 | 1 ",
6767
"succeed-legacy | 7.6.4 | test-succeed-legacy-instrumentation | true | 5 | 1 ",
6868
"succeed-multi-module-legacy | 7.6.4 | test-succeed-multi-module-legacy-instrumentation | true | 7 | 2 ",
6969
"succeed-multi-forks-legacy | 7.6.4 | test-succeed-multi-forks-legacy-instrumentation | true | 6 | 2 ",

0 commit comments

Comments
 (0)