Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

condy arrayindexoutofboundsexception fix #665

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion main/src/mockit/asm/constantPool/ConstantPoolGeneration.java
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,10 @@ public Item newConstItem(@Nonnull Object cst) {
if (cst instanceof MethodHandle) {
return newMethodHandleItem((MethodHandle) cst);
}

if(cst instanceof DynamicItem) {
DynamicItem dI = (DynamicItem)cst;
return createDynamicItem(dI.type, dI.name, dI.desc, dI.bsmIndex);
}
throw new IllegalArgumentException("value " + cst);
}

Expand Down
2 changes: 1 addition & 1 deletion main/src/mockit/asm/constantPool/DynamicItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

public final class DynamicItem extends TypeOrMemberItem
{
@Nonnegative private int bsmIndex;
@Nonnegative int bsmIndex;

public DynamicItem(@Nonnegative int index) { super(index); }

Expand Down
11 changes: 11 additions & 0 deletions main/src/mockit/asm/util/BytecodeReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import javax.annotation.*;

import mockit.asm.constantPool.DynamicItem;
import mockit.asm.jvmConstants.ConstantPoolTypes;
import mockit.asm.types.*;
import static mockit.asm.jvmConstants.ConstantPoolTypes.*;

Expand Down Expand Up @@ -394,6 +396,15 @@ protected final Object readConst(@Nonnegative int itemIndex) {
case MTYPE:
String methodDesc = readNonnullUTF8(constCodeIndex);
return MethodType.create(methodDesc);
case CONDY: {
int bsmStartIndex = readUnsignedShort(constCodeIndex);
int nameIndex = readItem(constCodeIndex + 2);
String name = readNonnullUTF8(nameIndex);
String desc = readNonnullUTF8(nameIndex + 2);
DynamicItem dynamicItem = new DynamicItem(itemIndex);
dynamicItem.set(ConstantPoolTypes.CONDY, name, desc, bsmStartIndex);
return dynamicItem;
}
// case HANDLE_BASE + [1..9]:
default:
return readMethodHandle(constCodeIndex);
Expand Down