diff --git a/docs/en-us/doc/release-note.md b/docs/en-us/doc/release-note.md index dbbea65..d73998f 100644 --- a/docs/en-us/doc/release-note.md +++ b/docs/en-us/doc/release-note.md @@ -1,5 +1,9 @@ # Release Note +## 0.4.10 +- fix an issue of using mock in lambda expression +- fix the NullPointerException when invoke private method with parameter value `null` + ## 0.4.9 - fix an issue cause by improperly bytecode processing while using `targetClass` parameter - auto validate access target of `PrivateAccessor`, improve resistance to code refactoring diff --git a/docs/zh-cn/doc/release-note.md b/docs/zh-cn/doc/release-note.md index 01295ab..5168327 100644 --- a/docs/zh-cn/doc/release-note.md +++ b/docs/zh-cn/doc/release-note.md @@ -1,5 +1,9 @@ # Release Note +## 0.4.10 +- 修复在Lambda函数中使用Mock出错的BUG(issue-44) +- 修复调用私有方法时参数值不能为null的问题(issue-27) + ## 0.4.9 - 修复发起调用的对象不是局部或成员变量时Mock出错的BUG (issue-40) - 增加`PrivateAccessor`访问目标有效性检查,提高抗代码重构能力 (issue-21) diff --git a/testable-agent/src/main/java/com/alibaba/testable/agent/handler/SourceClassHandler.java b/testable-agent/src/main/java/com/alibaba/testable/agent/handler/SourceClassHandler.java index 3322681..d299809 100644 --- a/testable-agent/src/main/java/com/alibaba/testable/agent/handler/SourceClassHandler.java +++ b/testable-agent/src/main/java/com/alibaba/testable/agent/handler/SourceClassHandler.java @@ -175,10 +175,11 @@ public class SourceClassHandler extends BaseClassHandler { case Opcodes.INVOKESPECIAL: case Opcodes.INVOKEVIRTUAL: case Opcodes.INVOKEINTERFACE: - return stackEffectOfInvocation(instruction) + 1; + return stackEffectOfInvocation(((MethodInsnNode)instruction).desc) + 1; case Opcodes.INVOKESTATIC: + return stackEffectOfInvocation(((MethodInsnNode)instruction).desc); case Opcodes.INVOKEDYNAMIC: - return stackEffectOfInvocation(instruction); + return stackEffectOfInvocation(((InvokeDynamicInsnNode)instruction).desc); case -1: // either LabelNode or LineNumberNode return 0; @@ -187,8 +188,7 @@ public class SourceClassHandler extends BaseClassHandler { } } - private int stackEffectOfInvocation(AbstractInsnNode instruction) { - String desc = ((MethodInsnNode)instruction).desc; + private int stackEffectOfInvocation(String desc) { return ClassUtil.getParameterTypes(desc).size() - (ClassUtil.getReturnType(desc).isEmpty() ? 0 : 1); }