}
@Test
public void testJumboStringConversion_NonMethodBuilder() throws IOException {
DexBuilder dexBuilder = DexBuilder.makeDexBuilder(15);
final List<Instruction> instructions = Lists.newArrayList();
for (int i=0; i<66000; i++) {
final StringReference ref = dexBuilder.internStringReference(String.format("%08d", i));
instructions.add(new Instruction21c() {
@Override public int getRegisterA() {
return 0;
}
@Nonnull @Override public Reference getReference() {
return ref;
}
@Override public int getReferenceType() { return ReferenceType.STRING; }
@Override public Opcode getOpcode() {
return Opcode.CONST_STRING;
}
@Override public int getCodeUnits() {
return getOpcode().format.size / 2;
}
});
}
instructions.add(new ImmutableInstruction10x(Opcode.RETURN_VOID));
MethodImplementation methodImpl = new MethodImplementation() {
@Override public int getRegisterCount() {
return 1;
}
@Nonnull @Override public Iterable<? extends Instruction> getInstructions() {
return instructions;
}
@Nonnull @Override public List<? extends TryBlock<? extends ExceptionHandler>> getTryBlocks() {
return ImmutableList.of();
}
@Nonnull @Override public Iterable<? extends DebugItem> getDebugItems() {
return ImmutableList.of();
}
};
dexBuilder.internClassDef(
"Ltest;",
0,
"Ljava/lang/Object;",
null,
null,
ImmutableSet.<Annotation>of(),
null,
ImmutableList.of(
dexBuilder.internMethod(
"Ltest;",
"test",
null,
"V",
0,
ImmutableSet.<Annotation>of(),
methodImpl)));
MemoryDataStore dexStore = new MemoryDataStore();
dexBuilder.writeTo(dexStore);
DexBackedDexFile dexFile = new DexBackedDexFile(new Opcodes(15), dexStore.getData());
ClassDef classDef = Iterables.getFirst(dexFile.getClasses(), null);
Assert.assertNotNull(classDef);