Fix muzzle failure on calls to primitive array clone
MODIFY
muzzle/src/main/java/io/opentelemetry/javaagent/tooling/muzzle/ReferenceCollectingClassVisitor.java
muzzle/src/main/java/io/opentelemetry/javaagent/tooling/muzzle/ReferenceCollectingClassVisitor.java
@@ -362,6 +362,12 @@ final class ReferenceCollectingClassVisitor extends ClassVisitor {
? underlyingType(Type.getType(owner))
: Type.getType("L" + owner + ";");
+ // method invoked on a primitive array type
+ if (ownerType.getSort() != Type.OBJECT) {
+ super.visitMethodInsn(opcode, owner, name, descriptor, isInterface);
+ return;
+ }
+
{ // ref for method return type
Type returnType = underlyingType(methodType.getReturnType());
if (returnType.getSort() == Type.OBJECT) {

MODIFY
muzzle/src/test/java/muzzle/TestClasses.java
muzzle/src/test/java/muzzle/TestClasses.java
@@ -14,6 +14,7 @@ import net.bytebuddy.asm.Advice;
public class TestClasses {
public static class MethodBodyAdvice {
+ @SuppressWarnings("ReturnValueIgnored")
@Advice.OnMethodEnter
public static void methodBodyAdvice() {
A a = new A();
@@ -24,6 +25,7 @@ public class TestClasses {
a.publicB.methodWithArrays(new String[0]);
B.staticMethod();
A.staticB.method("bar");
+ new int[0].clone();
}
public static class A {

Fix muzzle failure on calls to primitive array clone (#5405)