Skip to content

Commit 0b609a5

Browse files
jbachorikclaude
andcommitted
Fix HelperScanner: treat field/method types as USES not REQUIRES
The JVM only eagerly resolves superclass and interfaces during defineClass. Field types, method parameter/return types, and declared exceptions are resolved lazily. Marking them as REQUIRES created false dependency cycles that broke topological sort ordering when injecting large helper batches (2000+ classes). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5418feb commit 0b609a5

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/HelperScanner.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,10 @@ public FieldVisitor visitField(
156156
final String descriptor,
157157
final String signature,
158158
final Object value) {
159-
record(Type.getType(descriptor), REQUIRES);
159+
// Field types are resolved lazily by the JVM, not during defineClass.
160+
// Using USES (not REQUIRES) avoids false dependency cycles that can break
161+
// topological sort ordering for superclass/interface relationships.
162+
record(Type.getType(descriptor), USES);
160163
return null;
161164
}
162165

@@ -167,8 +170,11 @@ public MethodVisitor visitMethod(
167170
final String descriptor,
168171
final String signature,
169172
final String[] exceptions) {
170-
record(Type.getMethodType(descriptor), REQUIRES);
171-
record(exceptions, REQUIRES);
173+
// Method parameter/return types and declared exceptions are resolved lazily
174+
// by the JVM, not during defineClass. Only superclass and interfaces are
175+
// eagerly resolved, which are handled by visit().
176+
record(Type.getMethodType(descriptor), USES);
177+
record(exceptions, USES);
172178
return methodScanner;
173179
}
174180

0 commit comments

Comments
 (0)