From da3eca3d49298d23697cadbd64e1348f9051f4c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=87=91=E6=88=9F?= Date: Sat, 31 Oct 2020 22:29:22 +0800 Subject: [PATCH] mn.parameters could be null --- .../com/alibaba/testable/agent/handler/TestClassHandler.java | 3 ++- .../com/alibaba/testable/core/accessor/PrivateAccessor.java | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/testable-agent/src/main/java/com/alibaba/testable/agent/handler/TestClassHandler.java b/testable-agent/src/main/java/com/alibaba/testable/agent/handler/TestClassHandler.java index 9fbbf06..199ab38 100644 --- a/testable-agent/src/main/java/com/alibaba/testable/agent/handler/TestClassHandler.java +++ b/testable-agent/src/main/java/com/alibaba/testable/agent/handler/TestClassHandler.java @@ -52,6 +52,7 @@ public class TestClassHandler extends BaseClassHandler { private void handleAnnotation(ClassNode cn, MethodNode mn) { List visibleAnnotationNames = new ArrayList(); if (mn.visibleAnnotations == null) { + // let's assume test case should has a annotation, e.g. @Test or whatever return; } for (AnnotationNode n : mn.visibleAnnotations) { @@ -100,7 +101,7 @@ public class TestClassHandler extends BaseClassHandler { private void injectInvokeRecorder(MethodNode mn) { InsnList il = new InsnList(); List types = ClassUtil.getParameterTypes(mn.desc); - int size = mn.parameters.size(); + int size = types.size(); int parameterOffset = 1; il.add(getIntInsn(size)); il.add(new TypeInsnNode(ANEWARRAY, ClassUtil.CLASS_OBJECT)); diff --git a/testable-core/src/main/java/com/alibaba/testable/core/accessor/PrivateAccessor.java b/testable-core/src/main/java/com/alibaba/testable/core/accessor/PrivateAccessor.java index 63b2b7f..b57e547 100644 --- a/testable-core/src/main/java/com/alibaba/testable/core/accessor/PrivateAccessor.java +++ b/testable-core/src/main/java/com/alibaba/testable/core/accessor/PrivateAccessor.java @@ -1,6 +1,5 @@ package com.alibaba.testable.core.accessor; -import com.alibaba.testable.core.util.InvokeRecordUtil; import com.alibaba.testable.core.util.TypeUtil; import java.lang.reflect.Field;