Skip to content

Use @Classpath instead of @CompileClasspath for byteBuddy task inputs#1898

Open
trask wants to merge 1 commit intoraphw:masterfrom
trask:otel-cache-classpath-fix
Open

Use @Classpath instead of @CompileClasspath for byteBuddy task inputs#1898
trask wants to merge 1 commit intoraphw:masterfrom
trask:otel-cache-classpath-fix

Conversation

@trask
Copy link
Copy Markdown
Contributor

@trask trask commented Apr 26, 2026

Byte Buddy Plugin implementations can read full bytecode and resources from classes on the task's classPath — not just their public ABI. The Gradle tasks were annotating getClassPath() with @CompileClasspath, which fingerprints inputs using compile-avoidance hashing: method bodies, private members, and resources are normalized away. Two classpaths that share an ABI but differ in method bodies therefore produce the same cache key, causing the task to be reported UP_TO_DATE even when its output legitimately depends on the changed bytes.

Switch all four task classes (ByteBuddyTask, ByteBuddyJarTask, ByteBuddyJarsTask, ByteBuddySimpleTask, plus the WithIncrementalClassPath override) to @Classpath, which uses full content hashing while still preserving classpath-order semantics.

Adds an integration test (testClassPathFingerprintTracksMethodBodies) that builds a jar, re-runs to confirm UP_TO_DATE, then replaces the jar with a same-ABI/different-body variant and asserts the task re-executes.

@trask trask marked this pull request as ready for review April 26, 2026 22:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant