should always load array variable via aload

This commit is contained in:
金戟 2021-01-30 23:50:13 +08:00
parent 2bbe2eba93
commit ba951ce744
2 changed files with 8 additions and 1 deletions

View File

@ -115,17 +115,23 @@ public class ClassUtil {
public static List<Byte> getParameterTypes(String desc) {
List<Byte> parameterTypes = new ArrayList<Byte>();
boolean travelingClass = false;
boolean travelingArray = false;
for (byte b : desc.getBytes()) {
if (travelingClass) {
if (b == CLASS_END) {
travelingClass = false;
travelingArray = false;
}
} else {
if (isPrimaryType(b)) {
parameterTypes.add(b);
// should treat primary array as class (issue-48)
parameterTypes.add(travelingArray ? TYPE_CLASS : b);
travelingArray = false;
} else if (b == TYPE_CLASS) {
travelingClass = true;
parameterTypes.add(b);
} else if (b == TYPE_ARRAY) {
travelingArray = true;
} else if (b == PARAM_END) {
break;
}

View File

@ -25,6 +25,7 @@ public class InvokeRecordUtil {
* Record mock method invoke event
* @param args invocation parameters
* @param isConstructor whether mocked method is constructor
* @param isTargetClassInParameter whether use first parameter as target class
*/
public static void recordMockInvoke(Object[] args, boolean isConstructor, boolean isTargetClassInParameter) {
StackTraceElement mockMethodTraceElement = Thread.currentThread().getStackTrace()[INDEX_OF_TEST_CLASS];