Skip to content

Commit 2f95437

Browse files
authored
Ignore muzzle interface/field/return/param/constant references to tracer types that are guaranteed to exist (#3613)
1 parent 78ef9f8 commit 2f95437

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/muzzle/ReferenceCreator.java

+14-11
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,15 @@ public void visit(
188188

189189
// Add references to each of the interfaces.
190190
for (String iface : interfaces) {
191-
addReference(
192-
new Reference.Builder(iface)
193-
.withSource(
194-
refSourceClassName,
195-
UNDEFINED_LINE) // We don't have a specific line number to use.
196-
.withFlag(Reference.EXPECTS_PUBLIC)
197-
.build());
191+
if (!ignoreReference(iface)) {
192+
addReference(
193+
new Reference.Builder(iface)
194+
.withSource(
195+
refSourceClassName,
196+
UNDEFINED_LINE) // We don't have a specific line number to use.
197+
.withFlag(Reference.EXPECTS_PUBLIC)
198+
.build());
199+
}
198200
}
199201
// the super type is handled by the method visitor to the constructor.
200202
super.visit(version, access, name, signature, superName, interfaces);
@@ -286,7 +288,8 @@ public void visitFieldInsn(
286288

287289
final Type underlyingFieldType = underlyingType(fieldType);
288290
String underlyingFieldTypeInternalName = underlyingFieldType.getInternalName();
289-
if (underlyingFieldType.getSort() == Type.OBJECT) {
291+
if (underlyingFieldType.getSort() == Type.OBJECT
292+
&& !ignoreReference(underlyingFieldTypeInternalName)) {
290293
addReference(
291294
new Reference.Builder(underlyingFieldTypeInternalName)
292295
.withSource(refSourceClassName, currentLineNumber)
@@ -323,7 +326,7 @@ public void visitMethodInsn(
323326
{ // ref for method return type
324327
final Type returnType = underlyingType(methodType.getReturnType());
325328
String returnTypeInternalName = returnType.getInternalName();
326-
if (returnType.getSort() == Type.OBJECT) {
329+
if (returnType.getSort() == Type.OBJECT && !ignoreReference(returnTypeInternalName)) {
327330
addReference(
328331
new Reference.Builder(returnTypeInternalName)
329332
.withSource(refSourceClassName, currentLineNumber)
@@ -336,7 +339,7 @@ public void visitMethodInsn(
336339
for (Type paramType : methodType.getArgumentTypes()) {
337340
paramType = underlyingType(paramType);
338341
String paramTypeInternalName = paramType.getInternalName();
339-
if (paramType.getSort() == Type.OBJECT) {
342+
if (paramType.getSort() == Type.OBJECT && !ignoreReference(paramTypeInternalName)) {
340343
addReference(
341344
new Reference.Builder(paramTypeInternalName)
342345
.withSource(refSourceClassName, currentLineNumber)
@@ -425,7 +428,7 @@ public void visitLdcInsn(final Object value) {
425428
if (value instanceof Type) {
426429
final Type type = underlyingType((Type) value);
427430
String typeInternalName = type.getInternalName();
428-
if (type.getSort() == Type.OBJECT) {
431+
if (type.getSort() == Type.OBJECT && !ignoreReference(typeInternalName)) {
429432
addReference(
430433
new Reference.Builder(typeInternalName)
431434
.withSource(refSourceClassName, currentLineNumber)

0 commit comments

Comments
 (0)