/** * Returns the signed 32bit value at the given index. */ public int s32bitAt(int index) { return ByteArray.read32bit(bytecode, index); }
/** * Returns the signed 16bit value at the given index. */ public int s16bitAt(int index) { return ByteArray.readS16bit(bytecode, index); }
/** * Returns <code>local_variable_table[i].length</code>. * This represents the length of the code region in which the local * variable is effective. * * @param i the i-th entry. */ public int codeLength(int i) { return ByteArray.readU16bit(info, i * 10 + 4); }
/** * For each <code>local_variable_table[i].index</code>, * this method increases <code>index</code> by <code>delta</code>. * * @param lessThan the index does not change if it * is less than this value. */ public void shiftIndex(int lessThan, int delta) { int size = info.length; for (int i = 2; i < size; i += 10){ int org = ByteArray.readU16bit(info, i + 8); if (org >= lessThan) ByteArray.write16bit(org + delta, info, i + 8); } }
offset = newOffset(i, offset, where, gapLength, exclusive); newcode[j] = code[i]; ByteArray.write16bit(offset, newcode, j + 1); j += 3; int offset = ByteArray.read32bit(code, i + 1); offset = newOffset(i, offset, where, gapLength, exclusive); newcode[j++] = code[i]; ByteArray.write32bit(offset, newcode, j); j += 4; int defaultbyte = newOffset(i, ByteArray.read32bit(code, i2), where, gapLength, exclusive); ByteArray.write32bit(defaultbyte, newcode, j); int lowbyte = ByteArray.read32bit(code, i2 + 4); ByteArray.write32bit(lowbyte, newcode, j + 4); int highbyte = ByteArray.read32bit(code, i2 + 8); ByteArray.write32bit(highbyte, newcode, j + 8); j += 12; int i0 = i2 + 12; i2 = i0 + (highbyte - lowbyte + 1) * 4; while (i0 < i2) { int offset = newOffset(i, ByteArray.read32bit(code, i0), where, gapLength, exclusive); ByteArray.write32bit(offset, newcode, j); j += 4; i0 += 4; int defaultbyte = newOffset(i, ByteArray.read32bit(code, i2),
public void objectOrUninitialized(int tag, int data, int pos) { if (tag == UNINIT) if (where <= data) ByteArray.write16bit(data + gap, info, pos); } }
visitBranch(pos, code, ByteArray.readS16bit(code, pos + 1)); return 3; case Opcode.IF_ICMPEQ : case Opcode.IF_ACMPNE : stackTop -= 2; // branch visitBranch(pos, code, ByteArray.readS16bit(code, pos + 1)); return 3; case Opcode.GOTO : visitGoto(pos, code, ByteArray.readS16bit(code, pos + 1)); return 3; // branch case Opcode.JSR : int low = ByteArray.read32bit(code, pos2); int high = ByteArray.read32bit(code, pos2 + 4); int n = high - low + 1; visitTableSwitch(pos, code, n, pos2 + 8, ByteArray.read32bit(code, pos2 - 4)); return n * 4 + 16 - (pos & 3); } case Opcode.LOOKUPSWITCH : { int n = ByteArray.read32bit(code, pos2); visitLookupSwitch(pos, code, n, pos2 + 4, ByteArray.read32bit(code, pos2 - 4)); return n * 8 + 12 - (pos & 3); } case Opcode.IRETURN : return doInvokeDynamic(pos, code); case Opcode.NEW : { int i = ByteArray.readU16bit(code, pos + 1); stackTypes[stackTop++]
int write2(int dest, byte[] newcode) { ByteArray.write32bit(low, newcode, dest); ByteArray.write32bit(high, newcode, dest + 4); int n = offsets.length; dest += 8; for (int i = 0; i < n; i++) { ByteArray.write32bit(offsets[i], newcode, dest); dest += 4; } return 8 + 4 * n; }
offset = newOffset(i, offset, where, gapLength, exclusive); newcode[j] = code[i]; ByteArray.write16bit(offset, newcode, j + 1); j += 3; int offset = ByteArray.read32bit(code, i + 1); offset = newOffset(i, offset, where, gapLength, exclusive); newcode[j++] = code[i]; ByteArray.write32bit(offset, newcode, j); j += 4; int defaultbyte = newOffset(i, ByteArray.read32bit(code, i2), where, gapLength, exclusive); ByteArray.write32bit(defaultbyte, newcode, j); int lowbyte = ByteArray.read32bit(code, i2 + 4); ByteArray.write32bit(lowbyte, newcode, j + 4); int highbyte = ByteArray.read32bit(code, i2 + 8); ByteArray.write32bit(highbyte, newcode, j + 8); j += 12; int i0 = i2 + 12; i2 = i0 + (highbyte - lowbyte + 1) * 4; while (i0 < i2) { int offset = newOffset(i, ByteArray.read32bit(code, i0), where, gapLength, exclusive); ByteArray.write32bit(offset, newcode, j); j += 4; i0 += 4; int defaultbyte = newOffset(i, ByteArray.read32bit(code, i2),
int write(int srcPos, byte[] code, int destPos, byte[] newcode) { newcode[destPos] = LDC_W; ByteArray.write16bit(index, newcode, destPos + 1); return 2; } }
/** * Adjusts start_pc and length if bytecode is inserted in a method body. */ void shiftPc(int where, int gapLength, boolean exclusive) { int n = tableLength(); for (int i = 0; i < n; ++i) { int pos = i * 10 + 2; int pc = ByteArray.readU16bit(info, pos); int len = ByteArray.readU16bit(info, pos + 2); /* if pc == 0, then the local variable is a method parameter. */ if (pc > where || (exclusive && pc == where && pc != 0)) ByteArray.write16bit(pc + gapLength, info, pos); else if (pc + len > where || (exclusive && pc + len == where)) ByteArray.write16bit(len + gapLength, info, pos + 2); } }
visitBranch(pos, code, ByteArray.readS16bit(code, pos + 1)); return 3; case Opcode.IF_ICMPEQ : case Opcode.IF_ACMPNE : stackTop -= 2; // branch visitBranch(pos, code, ByteArray.readS16bit(code, pos + 1)); return 3; case Opcode.GOTO : visitGoto(pos, code, ByteArray.readS16bit(code, pos + 1)); return 3; // branch case Opcode.JSR : int low = ByteArray.read32bit(code, pos2); int high = ByteArray.read32bit(code, pos2 + 4); int n = high - low + 1; visitTableSwitch(pos, code, n, pos2 + 8, ByteArray.read32bit(code, pos2 - 4)); return n * 4 + 16 - (pos & 3); } case Opcode.LOOKUPSWITCH : { int n = ByteArray.read32bit(code, pos2); visitLookupSwitch(pos, code, n, pos2 + 4, ByteArray.read32bit(code, pos2 - 4)); return n * 8 + 12 - (pos & 3); } case Opcode.IRETURN : return doInvokeDynamic(pos, code); case Opcode.NEW : { int i = ByteArray.readU16bit(code, pos + 1); stackTypes[stackTop++]
int write2(int dest, byte[] newcode) { int n = matches.length; ByteArray.write32bit(n, newcode, dest); dest += 4; for (int i = 0; i < n; i++) { ByteArray.write32bit(matches[i], newcode, dest); ByteArray.write32bit(offsets[i], newcode, dest + 4); dest += 8; } return 4 + 8 * n; }
/** * Returns <code>line_number_table[i].line_number</code>. * This represents the corresponding line number in the original * source file. * * @param i the i-th entry. */ public int lineNumber(int i) { return ByteArray.readU16bit(info, i * 4 + 4); }
/** * Sets <code>exception_index_table[]</code>. */ public void setExceptionIndexes(int[] elist) { int n = elist.length; byte[] blist = new byte[n * 2 + 2]; ByteArray.write16bit(n, blist, 0); for (int i = 0; i < n; ++i) ByteArray.write16bit(elist[i], blist, i * 2 + 2); info = blist; }
public void visit() { int num = ByteArray.readU16bit(info, 0); ByteArray.write16bit(num, dest, 0); super.visit(); }
/** * Writes a 32bit integer at the index. */ public void write32bit(int value, int index) { ByteArray.write32bit(value, bytecode, index); }
/** * Returns the signed 32bit value at the given index. */ public int s32bitAt(int index) { return ByteArray.read32bit(bytecode, index); }
/** * Returns the signed 16bit value at the given index. */ public int s16bitAt(int index) { return ByteArray.readS16bit(bytecode, index); }
/** * Returns <code>local_variable_table_length</code>. * This represents the number of entries in the table. */ public int tableLength() { return ByteArray.readU16bit(info, 0); }