Skip to content

Commit

Permalink
Fixed bug where methods with many parameters could cause a NegativeAr…
Browse files Browse the repository at this point in the history
…raySizeException, due to byte overflow (the BIPUSH op); closes #333.
  • Loading branch information
rliesenfeld committed Sep 7, 2016
1 parent fdc3969 commit 7d4e545
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions main/src/mockit/internal/BaseClassModifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public static boolean generateCodeToPassThisOrNullIfStaticMethod(@Nonnull Method

public static void generateCodeToCreateArrayOfObject(@Nonnull MethodWriter mw, int arrayLength)
{
mw.visitIntInsn(BIPUSH, arrayLength);
mw.visitIntInsn(SIPUSH, arrayLength);
mw.visitTypeInsn(ANEWARRAY, "java/lang/Object");
}

Expand All @@ -158,7 +158,7 @@ public static void generateCodeToFillArrayWithParameterValues(

for (Type parameterType : parameterTypes) {
mw.visitInsn(DUP);
mw.visitIntInsn(BIPUSH, i++);
mw.visitIntInsn(SIPUSH, i++);
mw.visitVarInsn(parameterType.getOpcode(ILOAD), j);
TypeConversion.generateCastToObject(mw, parameterType);
mw.visitInsn(AASTORE);
Expand All @@ -175,7 +175,7 @@ protected final void generateCodeToObtainInstanceOfMockingBridge(@Nonnull Mockin
protected final void generateCodeToFillArrayElement(int arrayIndex, @Nullable Object value)
{
mw.visitInsn(DUP);
mw.visitIntInsn(BIPUSH, arrayIndex);
mw.visitIntInsn(SIPUSH, arrayIndex);

if (value == null) {
mw.visitInsn(ACONST_NULL);
Expand Down

0 comments on commit 7d4e545

Please sign in to comment.