public void update(BitSet exceptionTargets, BitSet branchTargets, InstructionList il, Set<Integer> finallyTargets, BitSet usedTargets) { int lastEnd = -1; InstructionHandle ih = il.findHandle(catchAnyAddress); if(ih == null || !(ih.getInstruction() instanceof ASTORE)) { incorrect = true; if(entry.getKey() > lastEnd) { int candidateStart = lastEnd; int block2end = equalBlocks(firstInstruction, il.findHandle(candidateStart), end-start, il.getInstructionPositions()); if(block2end > 0 && block2end <= entry.getKey()) { duplicates.put(candidateStart, block2end); break; InstructionHandle ih2 = il.findHandle(newKey); if(exceptionTargets.get(newKey)) {
InstructionHandle firstHandle = methodGen.getInstructionList().findHandle(first); InstructionHandle secondHandle = methodGen.getInstructionList().findHandle(second); while(true) { if(firstHandle == null || secondHandle == null) {
/** * Get instruction handle for instruction at byte code position pos. * This only works properly, if the list is freshly initialized from a byte array or * setPositions() has been called before this method. * * @param pos byte code position to search for * @return target position's instruction handle if available */ public InstructionHandle findHandle(int pos) { InstructionHandle[] ihs = getInstructionHandles(); return findHandle(ihs, byte_positions, length, pos); }
public void update(BitSet exceptionTargets, BitSet branchTargets, InstructionList il, Set<Integer> finallyTargets, BitSet usedTargets) { int lastEnd = -1; InstructionHandle ih = il.findHandle(catchAnyAddress); if(ih == null || !(ih.getInstruction() instanceof ASTORE)) { incorrect = true; if(entry.getKey() > lastEnd) { int candidateStart = lastEnd; int block2end = equalBlocks(firstInstruction, il.findHandle(candidateStart), end-start, il.getInstructionPositions()); if(block2end > 0 && block2end <= entry.getKey()) { duplicates.put(candidateStart, block2end); break; InstructionHandle ih2 = il.findHandle(newKey); if(exceptionTargets.get(newKey)) {
private void updateLocalVariableTable(final LocalVariableTable a) { final LocalVariable[] lv = a.getLocalVariableTable(); removeLocalVariables(); for (final LocalVariable l : lv) { InstructionHandle start = il.findHandle(l.getStartPC()); final InstructionHandle end = il.findHandle(l.getStartPC() + l.getLength()); // Repair malformed handles if (null == start) { start = il.getStart(); } // end == null => live to end of method // Since we are recreating the LocalVaraible, we must // propagate the orig_index to new copy. addLocalVariable(l.getName(), Type.getType(l.getSignature()), l .getIndex(), start, end, l.getOrigIndex()); } }
InstructionHandle ih = findHandle(ihs, pos, count, target); ih = findHandle(ihs, pos, count, target);
InstructionHandle ih = findHandle(ihs, pos, count, target); if (ih == null) { throw new ClassGenException("Couldn't find target for branch: " + bi); for (int j = 0; j < indices.length; j++) { target = bi.getPosition() + indices[j]; ih = findHandle(ihs, pos, count, target); if (ih == null) { throw new ClassGenException("Couldn't find target for switch: " + bi);
end = il.getEnd(); } else { end = il.findHandle(end_pc); addExceptionHandler(il.findHandle(ce.getStartPC()), end, il.findHandle(ce.getHandlerPC()), c_type); addLineNumber(il.findHandle(l.getStartPC()), l.getLineNumber()); InstructionHandle start = il.findHandle(l.getStartPC()); InstructionHandle end = il.findHandle(l.getStartPC() + l.getLength());
InstructionHandle firstHandle = methodGen.getInstructionList().findHandle(first); InstructionHandle secondHandle = methodGen.getInstructionList().findHandle(second); while(true) { if(firstHandle == null || secondHandle == null) {
end = il.getEnd(); } else { end = il.findHandle(end_pc); addExceptionHandler(il.findHandle(ce.getStartPC()), end, il.findHandle(ce .getHandlerPC()), c_type); final LineNumber[] ln = ((LineNumberTable) a).getLineNumberTable(); for (final LineNumber l : ln) { final InstructionHandle ih = il.findHandle(l.getStartPC()); if (ih != null) { addLineNumber(ih, l.getLineNumber());
/** * BCEL-262: */ public void testB262() throws ClassNotFoundException { final JavaClass clazz = getTestClass(PACKAGE_BASE_NAME+".data.PLSETestEnum"); final ClassGen gen = new ClassGen(clazz); final ConstantPoolGen pool = gen.getConstantPool(); // get the values() method final Method m = gen.getMethodAt(0); final MethodGen mg = new MethodGen(m, gen.getClassName(), pool); final InstructionList il = mg.getInstructionList(); // get the invokevirtual instruction final InstructionHandle ih = il.findHandle(3); final InvokeInstruction ii = (InvokeInstruction)(ih.getInstruction()); // without fix, the getClassName() will throw: // java.lang.IllegalArgumentException: Cannot be used on an array type final String cn = ii.getClassName(pool); assertEquals("[Lorg.apache.bcel.data.PLSETestEnum;", cn); }