com.sun.org.apache.bcel.internal.generic.ClassGenException
ClassGenException is described in the javadoc comments as:
Thrown on internal errors. Extends RuntimeException so it hasn't to be declared in the throws clause every time.
version: $Id: ClassGenException.java,v 1.1.1.1 2001/10/29 20:00:07 jvanzyl Exp $ author: M. Dahm
Where is this exception thrown?
Following, is a list of exception messages cross-referenced to the source code responsible for throwing them. Click on the method link to view the code and see how the exception is thrown.
- The message 'com.sun.org.apache.bcel.internal.generic.ClassGenException: ...' is thrown within the method:
com.sun.org.apache.bcel.internal.generic.Instruction.readInstruction(ByteSequence) - The message 'com.sun.org.apache.bcel.internal.generic.ClassGenException: ...' is thrown within the method:
com.sun.org.apache.bcel.internal.generic.InstructionList.getInstructions() - The message 'com.sun.org.apache.bcel.internal.generic.ClassGenException: Appending null InstructionList' is thrown within the method:
com.sun.org.apache.bcel.internal.generic.InstructionList.append(InstructionHandle, InstructionList) - The message 'com.sun.org.apache.bcel.internal.generic.ClassGenException: Appending null InstructionList' is thrown within the method:
com.sun.org.apache.bcel.internal.generic.InstructionList.append(InstructionList) - The message 'com.sun.org.apache.bcel.internal.generic.ClassGenException: Assigning ... to branch handle which is not a branch instruction' is thrown within the method:
com.sun.org.apache.bcel.internal.generic.BranchHandle.setInstruction(Instruction) - The message 'com.sun.org.apache.bcel.internal.generic.ClassGenException: Assigning branch instruction ... to plain handle' is thrown within the method:
com.sun.org.apache.bcel.internal.generic.InstructionHandle.setInstruction(Instruction) - The message 'com.sun.org.apache.bcel.internal.generic.ClassGenException: Assigning null to handle' is thrown within the method:
com.sun.org.apache.bcel.internal.generic.InstructionHandle.setInstruction(Instruction) - The message 'com.sun.org.apache.bcel.internal.generic.ClassGenException: Branch instruction ... : ... not contained in BranchHandle.' is thrown within the method:
com.sun.org.apache.bcel.internal.generic.InstructionList.setPositions(boolean) - The message 'com.sun.org.apache.bcel.internal.generic.ClassGenException: Branch target of ... : ... not in instruction list' is thrown within the method:
com.sun.org.apache.bcel.internal.generic.InstructionList.setPositions(boolean) - The message 'com.sun.org.apache.bcel.internal.generic.ClassGenException: Branch target offset too large for short' is thrown within the method:
com.sun.org.apache.bcel.internal.generic.BranchInstruction.dump(DataOutputStream) - The message 'com.sun.org.apache.bcel.internal.generic.ClassGenException: Exception handler target is null instruction' is thrown within the method:
com.sun.org.apache.bcel.internal.generic.MethodGen.addExceptionHandler(InstructionHandle, InstructionHandle, InstructionHandle, ObjectType) - The message 'com.sun.org.apache.bcel.internal.generic.ClassGenException: Illegal opcode detected.' is thrown within the method:
com.sun.org.apache.bcel.internal.generic.Instruction.readInstruction(ByteSequence) - The message 'com.sun.org.apache.bcel.internal.generic.ClassGenException: Illegal value: ...' is thrown within the method:
com.sun.org.apache.bcel.internal.generic.LocalVariableInstruction.setIndex(int) - The message 'com.sun.org.apache.bcel.internal.generic.ClassGenException: Inserting null InstructionList' is thrown within the method:
com.sun.org.apache.bcel.internal.generic.InstructionList.insert(InstructionHandle, InstructionList) - The message 'com.sun.org.apache.bcel.internal.generic.ClassGenException: Instruction ... is not contained in this list.' is thrown within the method:
com.sun.org.apache.bcel.internal.generic.InstructionList.append(Instruction, InstructionList) - The message 'com.sun.org.apache.bcel.internal.generic.ClassGenException: Instruction ... is not contained in this list.' is thrown within the method:
com.sun.org.apache.bcel.internal.generic.InstructionList.delete(Instruction) - The message 'com.sun.org.apache.bcel.internal.generic.ClassGenException: Instruction ... is not contained in this list.' is thrown within the method:
com.sun.org.apache.bcel.internal.generic.InstructionList.delete(Instruction, Instruction) - The message 'com.sun.org.apache.bcel.internal.generic.ClassGenException: Instruction ... is not contained in this list.' is thrown within the method:
com.sun.org.apache.bcel.internal.generic.InstructionList.insert(Instruction, InstructionList) - The message 'com.sun.org.apache.bcel.internal.generic.ClassGenException: Instruction handle ... not found in instruction list.' is thrown within the method:
com.sun.org.apache.bcel.internal.util.InstructionFinder.search(String, InstructionHandle, CodeConstraint) - The message 'com.sun.org.apache.bcel.internal.generic.ClassGenException: Invalid branch target position offset for ... : ... : ...' is thrown within the method:
com.sun.org.apache.bcel.internal.generic.BranchInstruction.getTargetOffset(InstructionHandle) - The message 'com.sun.org.apache.bcel.internal.generic.ClassGenException: Invalid null handle: From ... to ...' is thrown within the method:
com.sun.org.apache.bcel.internal.generic.InstructionList.move(InstructionHandle, InstructionHandle, InstructionHandle) - The message 'com.sun.org.apache.bcel.internal.generic.ClassGenException: Invalid range: From ... to ...' is thrown within the method:
com.sun.org.apache.bcel.internal.generic.InstructionList.move(InstructionHandle, InstructionHandle, InstructionHandle) - The message 'com.sun.org.apache.bcel.internal.generic.ClassGenException: Invalid range: From ... to ... contains target ...' is thrown within the method:
com.sun.org.apache.bcel.internal.generic.InstructionList.move(InstructionHandle, InstructionHandle, InstructionHandle) - The message 'com.sun.org.apache.bcel.internal.generic.ClassGenException: Invalid type: ...' is thrown within the method:
com.sun.org.apache.bcel.internal.generic.BasicType.getType(byte) - The message 'com.sun.org.apache.bcel.internal.generic.ClassGenException: Negative index value: ...' is thrown within the method:
com.sun.org.apache.bcel.internal.generic.CPInstruction.setIndex(int) - The message 'com.sun.org.apache.bcel.internal.generic.ClassGenException: Negative index value: ...' is thrown within the method:
com.sun.org.apache.bcel.internal.generic.IINC.setIndex(int) - The message 'com.sun.org.apache.bcel.internal.generic.ClassGenException: Negative index value: ...' is thrown within the method:
com.sun.org.apache.bcel.internal.generic.RET.setIndex(int) - The message 'com.sun.org.apache.bcel.internal.generic.ClassGenException: Not targeting ...' is thrown within the method:
com.sun.org.apache.bcel.internal.generic.Select.updateTarget(InstructionHandle, InstructionHandle) - The message 'com.sun.org.apache.bcel.internal.generic.ClassGenException: Not targeting ... , but ...' is thrown within the method:
com.sun.org.apache.bcel.internal.generic.BranchInstruction.updateTarget(InstructionHandle, InstructionHandle) - The message 'com.sun.org.apache.bcel.internal.generic.ClassGenException: Not targeting ... , but ... }' is thrown within the method:
com.sun.org.apache.bcel.internal.generic.LineNumberGen.updateTarget(InstructionHandle, InstructionHandle) - The message 'com.sun.org.apache.bcel.internal.generic.ClassGenException: Not targeting ... , but { ... , ... , ... }' is thrown within the method:
com.sun.org.apache.bcel.internal.generic.CodeExceptionGen.updateTarget(InstructionHandle, InstructionHandle) - The message 'com.sun.org.apache.bcel.internal.generic.ClassGenException: Not targeting ... , but { ... , ... }' is thrown within the method:
com.sun.org.apache.bcel.internal.generic.LocalVariableGen.updateTarget(InstructionHandle, InstructionHandle) - The message 'com.sun.org.apache.bcel.internal.generic.ClassGenException: Only final fields may have an initial value!' is thrown within the method:
com.sun.org.apache.bcel.internal.generic.FieldGen.checkType(Type) - The message 'com.sun.org.apache.bcel.internal.generic.ClassGenException: Oops: unknown case in switch ...' is thrown within the method:
com.sun.org.apache.bcel.internal.generic.ArrayInstruction.getType(ConstantPoolGen) - The message 'com.sun.org.apache.bcel.internal.generic.ClassGenException: Oops: unknown case in switch ...' is thrown within the method:
com.sun.org.apache.bcel.internal.generic.LocalVariableInstruction.getType(ConstantPoolGen) - The message 'com.sun.org.apache.bcel.internal.generic.ClassGenException: Padding byte != 0: ...' is thrown within the method:
com.sun.org.apache.bcel.internal.generic.Select.initFromFile(ByteSequence, boolean) - The message 'com.sun.org.apache.bcel.internal.generic.ClassGenException: Replacement method must not be null' is thrown within the method:
com.sun.org.apache.bcel.internal.generic.ClassGen.replaceField(Field, Field) - The message 'com.sun.org.apache.bcel.internal.generic.ClassGenException: Replacement method must not be null' is thrown within the method:
com.sun.org.apache.bcel.internal.generic.ClassGen.replaceMethod(Method, Method) - The message 'com.sun.org.apache.bcel.internal.generic.ClassGenException: Target of ... is invalid null handle' is thrown within the method:
com.sun.org.apache.bcel.internal.generic.BranchInstruction.getTargetOffset(InstructionHandle) - The message 'com.sun.org.apache.bcel.internal.generic.ClassGenException: Types are not compatible: ... vs. ...' is thrown within the method:
com.sun.org.apache.bcel.internal.generic.FieldGen.checkType(Type) - The message 'com.sun.org.apache.bcel.internal.generic.ClassGenException: Unknown type ...' is thrown within the method:
com.sun.org.apache.bcel.internal.generic.ArithmeticInstruction.getType(ConstantPoolGen) - The message 'com.sun.org.apache.bcel.internal.generic.ClassGenException: Unknown type ...' is thrown within the method:
com.sun.org.apache.bcel.internal.generic.ConversionInstruction.getType(ConstantPoolGen) - The message 'com.sun.org.apache.bcel.internal.generic.ClassGenException: Unknown type ...' is thrown within the method:
com.sun.org.apache.bcel.internal.generic.ReturnInstruction.getType() - The message 'com.sun.org.apache.bcel.internal.generic.ClassGenException: You haven't defined the type of the field yet' is thrown within the method:
com.sun.org.apache.bcel.internal.generic.FieldGen.checkType(Type)
How is this exception thrown?
The following sub-sections identify where this exception is thrown, and how (or why) the code is throwing the exception.
Any source code quoted in this section is subject to the Java Research License unless stated otherwise.
com.sun.org.apache.bcel.internal.generic.Instruction.readInstruction(ByteSequence)
/** * Read an instruction from (byte code) input stream and return the * appropiate object. * @param file file to read from * @return instruction object being read */ public static final Instruction readInstruction(ByteSequence bytes) throws IOException { boolean wide = false; short opcode = (short) bytes.readUnsignedByte(); Instruction obj = null; if (opcode == Constants.WIDE) { wide = true; opcode = (short) bytes.readUnsignedByte(); } if (InstructionConstants.INSTRUCTIONS[opcode] != null) return InstructionConstants.INSTRUCTIONS[opcode]; Class clazz; try { clazz = Class.forName(className(opcode)); } catch (ClassNotFoundException cnfe) { throw new ClassGenException('Illegal opcode detected.'); } try { obj = (Instruction) clazz.newInstance(); if (wide && !((obj instanceof LocalVariableInstruction) || (obj instanceof IINC) || (obj instanceof RET))) throw new Exception('Illegal opcode after wide: ' + opcode); obj.setOpcode(opcode); obj.initFromFile(bytes, wide); } catch (Exception e) { throw new ClassGenException(e.toString()); } return obj; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.generic.InstructionList.getInstructions()
/** * @return an array of instructions without target information for branch instructions. */ public Instruction[] getInstructions() { ByteSequence bytes = new ByteSequence(getByteCode()); ArrayList instructions = new ArrayList(); try { while (bytes.available() > 0) { instructions.add(Instruction.readInstruction(bytes)); } } catch (IOException e) { throw new ClassGenException(e.toString()); } Instruction[] result = new Instruction[instructions.size()]; instructions.toArray(result); return result; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.generic.InstructionList.append(InstructionHandle, InstructionList)
/** * Append another list after instruction (handle) ih contained in this list. * Consumes argument list, i.e., it becomes empty. * @param ih where to append the instruction list * @param il Instruction list to append to this one * @return instruction handle pointing to the <B>first</B> appended instruction */ public InstructionHandle append(InstructionHandle ih, InstructionList il) { if (il == null) throw new ClassGenException('Appending null InstructionList'); if (il.isEmpty()) return ih; InstructionHandle next = ih.next, ret = il.start; ih.next = il.start; il.start.prev = ih; il.end.next = next; if (next != null) next.prev = il.end; else end = il.end; length += il.length; il.clear(); return ret; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.generic.InstructionList.append(InstructionList)
/** * Append another list to this one. * Consumes argument list, i.e., it becomes empty. * @param il list to append to end of this list * @return instruction handle of the <B>first</B> appended instruction */ public InstructionHandle append(InstructionList il) { if (il == null) throw new ClassGenException('Appending null InstructionList'); if (il.isEmpty()) return null; if (isEmpty()) { start = il.start; end = il.end; length = il.length; il.clear(); return start; } else return append(end, il); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.generic.BranchHandle.setInstruction(Instruction)
/** * Set new contents. Old instruction is disposed and may not be used anymore. */ public void setInstruction(Instruction i) { super.setInstruction(i); if (!(i instanceof BranchInstruction)) throw new ClassGenException('Assigning ' + i + ' to branch handle which is not a branch instruction'); bi = (BranchInstruction) i; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.generic.InstructionHandle.setInstruction(Instruction)
/** * Replace current instruction contained in this handle. * Old instruction is disposed using Instruction.dispose(). */ public void setInstruction(Instruction i) { if (i == null) throw new ClassGenException('Assigning null to handle'); if ((this.getClass() != BranchHandle.class) && (i instanceof BranchInstruction)) throw new ClassGenException('Assigning branch instruction ' + i + ' to plain handle'); if (instruction != null) instruction.dispose(); instruction = i; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.generic.InstructionList.setPositions(boolean)
/** * Give all instructions their position number (offset in byte stream), i.e., * make the list ready to be dumped. * @param check Perform sanity checks, e.g. if all targeted instructions really belong * to this list */ public void setPositions(boolean check) { int max_additional_bytes = 0, additional_bytes = 0; int index = 0, count = 0; int[] pos = new int[length]; if (check) { for (InstructionHandle ih = start; ih != null; ih = ih.next) { Instruction i = ih.instruction; if (i instanceof BranchInstruction) { Instruction inst = ((BranchInstruction) i).getTarget().instruction; if (!contains(inst)) throw new ClassGenException('Branch target of ' + Constants.OPCODE_NAMES[i.opcode] + ':' + inst + ' not in instruction list'); if (i instanceof Select) { InstructionHandle[] targets = ((Select) i).getTargets(); for (int j = 0; j < targets.length; j++) { inst = targets[j].instruction; if (!contains(inst)) throw new ClassGenException('Branch target of ' + Constants.OPCODE_NAMES[i.opcode] + ':' + inst + ' not in instruction list'); } } if (!(ih instanceof BranchHandle)) throw new ClassGenException('Branch instruction ' + Constants.OPCODE_NAMES[i.opcode] + ':' + inst + ' not contained in BranchHandle.'); } } } for (InstructionHandle ih = start; ih != null; ih = ih.next) { Instruction i = ih.instruction; ih.setPosition(index); pos[count++] = index; switch(i.getOpcode()) { case Constants.JSR: case Constants.GOTO: max_additional_bytes += 2; break; case Constants.TABLESWITCH: case Constants.LOOKUPSWITCH: max_additional_bytes += 3; break; } index += i.getLength(); } for (InstructionHandle ih = start; ih != null; ih = ih.next) additional_bytes += ih.updatePosition(additional_bytes, max_additional_bytes); index = count = 0; for (InstructionHandle ih = start; ih != null; ih = ih.next) { Instruction i = ih.instruction; ih.setPosition(index); pos[count++] = index; index += i.getLength(); } byte_positions = new int[count]; System.arraycopy(pos, 0, byte_positions, 0, count); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.generic.BranchInstruction.dump(DataOutputStream)
/** * Dump instruction as byte code to stream out. * @param out Output stream */ public void dump(DataOutputStream out) throws IOException { out.writeByte(opcode); index = getTargetOffset(); if (Math.abs(index) >= 32767) throw new ClassGenException('Branch target offset too large for short'); out.writeShort(index); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.generic.MethodGen.addExceptionHandler(InstructionHandle, InstructionHandle, InstructionHandle, ObjectType)
/** * Add an exception handler, i.e., specify region where a handler is active and an * instruction where the actual handling is done. * @param start_pc Start of region (inclusive) * @param end_pc End of region (inclusive) * @param handler_pc Where handling is done * @param catch_type fully qualified class name of handled exception or null if any * exception is handled * @return new exception handler object */ public CodeExceptionGen addExceptionHandler(InstructionHandle start_pc, InstructionHandle end_pc, InstructionHandle handler_pc, ObjectType catch_type) { if ((start_pc == null) || (end_pc == null) || (handler_pc == null)) throw new ClassGenException('Exception handler target is null instruction'); CodeExceptionGen c = new CodeExceptionGen(start_pc, end_pc, handler_pc, catch_type); exception_vec.add(c); return c; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.generic.LocalVariableInstruction.setIndex(int)
/** * Set the local variable index */ public void setIndex(int n) { if ((n < 0) || (n > Constants.MAX_SHORT)) throw new ClassGenException('Illegal value: ' + n); this.n = n; if (n >= 0 && n <= 3) { opcode = (short) (c_tag + n); length = 1; } else { opcode = canon_tag; if (wide()) length = 4; else length = 2; } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.generic.InstructionList.insert(InstructionHandle, InstructionList)
/** * Insert another list before Instruction handle ih contained in this list. * Consumes argument list, i.e., it becomes empty. * @param i where to append the instruction list * @param il Instruction list to insert * @return instruction handle of the first inserted instruction */ public InstructionHandle insert(InstructionHandle ih, InstructionList il) { if (il == null) throw new ClassGenException('Inserting null InstructionList'); if (il.isEmpty()) return ih; InstructionHandle prev = ih.prev, ret = il.start; ih.prev = il.end; il.end.next = ih; il.start.prev = prev; if (prev != null) prev.next = il.start; else start = il.start; length += il.length; il.clear(); return ret; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.generic.InstructionList.append(Instruction, InstructionList)
/** * Append another list after instruction i contained in this list. * Consumes argument list, i.e., it becomes empty. * @param i where to append the instruction list * @param il Instruction list to append to this one * @return instruction handle pointing to the <B>first</B> appended instruction */ public InstructionHandle append(Instruction i, InstructionList il) { InstructionHandle ih; if ((ih = findInstruction2(i)) == null) throw new ClassGenException('Instruction ' + i + ' is not contained in this list.'); return append(ih, il); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.generic.InstructionList.delete(Instruction)
/** * Remove instruction from this list. The corresponding Instruction * handles must not be reused! * @param i instruction to remove */ public void delete(Instruction i) throws TargetLostException { InstructionHandle ih; if ((ih = findInstruction1(i)) == null) throw new ClassGenException('Instruction ' + i + ' is not contained in this list.'); delete(ih); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.generic.InstructionList.delete(Instruction, Instruction)
/** * Remove instructions from instruction `from' to instruction `to' contained * in this list. The user must ensure that `from' is an instruction before * `to', or risk havoc. The corresponding Instruction handles must not be reused! * @param from where to start deleting (inclusive) * @param to where to end deleting (inclusive) */ public void delete(Instruction from, Instruction to) throws TargetLostException { InstructionHandle from_ih, to_ih; if ((from_ih = findInstruction1(from)) == null) throw new ClassGenException('Instruction ' + from + ' is not contained in this list.'); if ((to_ih = findInstruction2(to)) == null) throw new ClassGenException('Instruction ' + to + ' is not contained in this list.'); delete(from_ih, to_ih); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.generic.InstructionList.insert(Instruction, InstructionList)
/** * Insert another list before Instruction i contained in this list. * Consumes argument list, i.e., it becomes empty. * @param i where to append the instruction list * @param il Instruction list to insert * @return instruction handle pointing to the first inserted instruction, * i.e., il.getStart() */ public InstructionHandle insert(Instruction i, InstructionList il) { InstructionHandle ih; if ((ih = findInstruction1(i)) == null) throw new ClassGenException('Instruction ' + i + ' is not contained in this list.'); return insert(ih, il); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.util.InstructionFinder.search(String, InstructionHandle, CodeConstraint)
/** * Search for the given pattern in the instruction list. You can search for any valid * opcode via its symbolic name, e.g. 'istore'. You can also use a super class or * an interface name to match a whole set of instructions, e.g. 'BranchInstruction' or * 'LoadInstruction'. 'istore' is also an alias for all 'istore_x' instructions. Additional * aliases are 'if' for 'ifxx', 'if_icmp' for 'if_icmpxx', 'if_acmp' for 'if_acmpxx'. * Consecutive instruction names must be separated by white space which will be removed * during the compilation of the pattern. * For the rest the usual pattern matching rules for regular expressions apply.<P> * Example pattern: search('BranchInstruction NOP ((IfInstruction|GOTO)+ ISTORE Instruction)*'); * * If you alter the instruction list upon a match such that other * matching areas are affected, you should call reread() to update * the finder and call search() again, because the matches are cached. * @param pattern the instruction pattern to search for, where case is ignored * @param from where to start the search in the instruction list * @param constraint optional CodeConstraint to check the found code pattern for * user-defined constraints * @return iterator of matches where e.nextElement() returns an array of instruction handles * describing the matched area */ public final Iterator search(String pattern, InstructionHandle from, CodeConstraint constraint) { String search = compilePattern(pattern); int start = -1; for (int i = 0; i < handles.length; i++) { if (handles[i] == from) { start = i; break; } } if (start == -1) throw new ClassGenException('Instruction handle ' + from + ' not found in instruction list.'); try { RE regex = new RE(search); ArrayList matches = new ArrayList(); while (start < il_string.length() && regex.match(il_string, start)) { int startExpr = regex.getParenStart(0); int endExpr = regex.getParenEnd(0); int lenExpr = regex.getParenLength(0); InstructionHandle[] match = getMatch(startExpr, lenExpr); if ((constraint == null) || constraint.checkCode(match)) matches.add(match); start = endExpr; } return matches.iterator(); } catch (RESyntaxException e) { System.err.println(e); } return null; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.generic.BranchInstruction.getTargetOffset(InstructionHandle)
/** * @param target branch target * @return the offset to `target' relative to this instruction */ protected int getTargetOffset(InstructionHandle target) { if (target == null) throw new ClassGenException('Target of ' + super.toString(true) + ' is invalid null handle'); int t = target.getPosition(); if (t < 0) throw new ClassGenException('Invalid branch target position offset for ' + super.toString(true) + ':' + t + ':' + target); return t - position; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.generic.InstructionList.move(InstructionHandle, InstructionHandle, InstructionHandle)
/** * Take all instructions (handles) from 'start' to 'end' and append them after the * new location 'target'. Of course, 'end' must be after 'start' and target must * not be located withing this range. If you want to move something to the start of * the list use null as value for target. * Any instruction targeters pointing to handles within the block, keep their targets. * @param start of moved block * @param end of moved block * @param target of moved block */ public void move(InstructionHandle start, InstructionHandle end, InstructionHandle target) { if ((start == null) || (end == null)) throw new ClassGenException('Invalid null handle: From ' + start + ' to ' + end); if ((target == start) || (target == end)) throw new ClassGenException('Invalid range: From ' + start + ' to ' + end + ' contains target ' + target); for (InstructionHandle ih = start; ih != end.next; ih = ih.next) { if (ih == null) throw new ClassGenException('Invalid range: From ' + start + ' to ' + end); else if (ih == target) throw new ClassGenException('Invalid range: From ' + start + ' to ' + end + ' contains target ' + target); } InstructionHandle prev = start.prev, next = end.next; if (prev != null) prev.next = next; else this.start = next; if (next != null) next.prev = prev; else this.end = prev; start.prev = end.next = null; if (target == null) { end.next = this.start; this.start = start; } else { next = target.next; target.next = start; start.prev = target; end.next = next; if (next != null) next.prev = end; } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.generic.BasicType.getType(byte)
public static final BasicType getType(byte type) { switch(type) { case Constants.T_VOID: return VOID; case Constants.T_BOOLEAN: return BOOLEAN; case Constants.T_BYTE: return BYTE; case Constants.T_SHORT: return SHORT; case Constants.T_CHAR: return CHAR; case Constants.T_INT: return INT; case Constants.T_LONG: return LONG; case Constants.T_DOUBLE: return DOUBLE; case Constants.T_FLOAT: return FLOAT; default: throw new ClassGenException('Invalid type: ' + type); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.generic.CPInstruction.setIndex(int)
/** * Set the index to constant pool. * @param index in constant pool. */ public void setIndex(int index) { if (index < 0) throw new ClassGenException('Negative index value: ' + index); this.index = index; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.generic.IINC.setIndex(int)
/** * Set index of local variable. */ public final void setIndex(int n) { if (n < 0) throw new ClassGenException('Negative index value: ' + n); this.n = n; setWide(); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.generic.RET.setIndex(int)
/** * Set index of local variable containg the return address */ public final void setIndex(int n) { if (n < 0) throw new ClassGenException('Negative index value: ' + n); index = n; setWide(); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.generic.Select.updateTarget(InstructionHandle, InstructionHandle)
/** * @param old_ih old target * @param new_ih new target */ public void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih) { boolean targeted = false; if (target == old_ih) { targeted = true; setTarget(new_ih); } for (int i = 0; i < targets.length; i++) { if (targets[i] == old_ih) { targeted = true; setTarget(i, new_ih); } } if (!targeted) throw new ClassGenException('Not targeting ' + old_ih); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.generic.BranchInstruction.updateTarget(InstructionHandle, InstructionHandle)
/** * @param old_ih old target * @param new_ih new target */ public void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih) { if (target == old_ih) setTarget(new_ih); else throw new ClassGenException('Not targeting ' + old_ih + ', but ' + target); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.generic.LineNumberGen.updateTarget(InstructionHandle, InstructionHandle)
/** * @param old_ih old target * @param new_ih new target */ public void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih) { if (old_ih != ih) throw new ClassGenException('Not targeting ' + old_ih + ', but ' + ih + '}'); else setInstruction(new_ih); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.generic.CodeExceptionGen.updateTarget(InstructionHandle, InstructionHandle)
/** * @param old_ih old target, either start or end * @param new_ih new target */ public void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih) { boolean targeted = false; if (start_pc == old_ih) { targeted = true; setStartPC(new_ih); } if (end_pc == old_ih) { targeted = true; setEndPC(new_ih); } if (handler_pc == old_ih) { targeted = true; setHandlerPC(new_ih); } if (!targeted) throw new ClassGenException('Not targeting ' + old_ih + ', but {' + start_pc + ', ' + end_pc + ', ' + handler_pc + '}'); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.generic.LocalVariableGen.updateTarget(InstructionHandle, InstructionHandle)
/** * @param old_ih old target, either start or end * @param new_ih new target */ public void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih) { boolean targeted = false; if (start == old_ih) { targeted = true; setStart(new_ih); } if (end == old_ih) { targeted = true; setEnd(new_ih); } if (!targeted) throw new ClassGenException('Not targeting ' + old_ih + ', but {' + start + ', ' + end + '}'); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.generic.FieldGen.checkType(Type)
private void checkType(Type atype) { if (type == null) throw new ClassGenException('You haven't defined the type of the field yet'); if (!isFinal()) throw new ClassGenException('Only final fields may have an initial value!'); if (!type.equals(atype)) throw new ClassGenException('Types are not compatible: ' + type + ' vs. ' + atype); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.generic.ArrayInstruction.getType(ConstantPoolGen)
/** @return type associated with the instruction */ public Type getType(ConstantPoolGen cp) { switch(opcode) { case com.sun.org.apache.bcel.internal.Constants.IALOAD: case com.sun.org.apache.bcel.internal.Constants.IASTORE: return Type.INT; case com.sun.org.apache.bcel.internal.Constants.CALOAD: case com.sun.org.apache.bcel.internal.Constants.CASTORE: return Type.CHAR; case com.sun.org.apache.bcel.internal.Constants.BALOAD: case com.sun.org.apache.bcel.internal.Constants.BASTORE: return Type.BYTE; case com.sun.org.apache.bcel.internal.Constants.SALOAD: case com.sun.org.apache.bcel.internal.Constants.SASTORE: return Type.SHORT; case com.sun.org.apache.bcel.internal.Constants.LALOAD: case com.sun.org.apache.bcel.internal.Constants.LASTORE: return Type.LONG; case com.sun.org.apache.bcel.internal.Constants.DALOAD: case com.sun.org.apache.bcel.internal.Constants.DASTORE: return Type.DOUBLE; case com.sun.org.apache.bcel.internal.Constants.FALOAD: case com.sun.org.apache.bcel.internal.Constants.FASTORE: return Type.FLOAT; case com.sun.org.apache.bcel.internal.Constants.AALOAD: case com.sun.org.apache.bcel.internal.Constants.AASTORE: return Type.OBJECT; default: throw new ClassGenException('Oops: unknown case in switch' + opcode); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.generic.LocalVariableInstruction.getType(ConstantPoolGen)
/** * Returns the type associated with the instruction - * in case of ALOAD or ASTORE Type.OBJECT is returned. * This is just a bit incorrect, because ALOAD and ASTORE * may work on every ReferenceType (including Type.NULL) and * ASTORE may even work on a ReturnaddressType . * @return type associated with the instruction */ public Type getType(ConstantPoolGen cp) { switch(canon_tag) { case Constants.ILOAD: case Constants.ISTORE: return Type.INT; case Constants.LLOAD: case Constants.LSTORE: return Type.LONG; case Constants.DLOAD: case Constants.DSTORE: return Type.DOUBLE; case Constants.FLOAD: case Constants.FSTORE: return Type.FLOAT; case Constants.ALOAD: case Constants.ASTORE: return Type.OBJECT; default: throw new ClassGenException('Oops: unknown case in switch' + canon_tag); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.generic.Select.initFromFile(ByteSequence, boolean)
/** * Read needed data (e.g. index) from file. */ protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException { padding = (4 - (bytes.getIndex() % 4)) % 4; for (int i = 0; i < padding; i++) { byte b; if ((b = bytes.readByte()) != 0) throw new ClassGenException('Padding byte != 0: ' + b); } index = bytes.readInt(); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.generic.ClassGen.replaceField(Field, Field)
/** Replace given field with new one. If the old one does not exist * add the new_ field to the class anyway. */ public void replaceField(Field old, Field new_) { if (new_ == null) throw new ClassGenException('Replacement method must not be null'); int i = field_vec.indexOf(old); if (i < 0) field_vec.add(new_); else field_vec.set(i, new_); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.generic.ClassGen.replaceMethod(Method, Method)
/** Replace given method with new one. If the old one does not exist * add the new_ method to the class anyway. */ public void replaceMethod(Method old, Method new_) { if (new_ == null) throw new ClassGenException('Replacement method must not be null'); int i = method_vec.indexOf(old); if (i < 0) method_vec.add(new_); else method_vec.set(i, new_); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.generic.ArithmeticInstruction.getType(ConstantPoolGen)
/** @return type associated with the instruction */ public Type getType(ConstantPoolGen cp) { switch(opcode) { case Constants.DADD: case Constants.DDIV: case Constants.DMUL: case Constants.DNEG: case Constants.DREM: case Constants.DSUB: return Type.DOUBLE; case Constants.FADD: case Constants.FDIV: case Constants.FMUL: case Constants.FNEG: case Constants.FREM: case Constants.FSUB: return Type.FLOAT; case Constants.IADD: case Constants.IAND: case Constants.IDIV: case Constants.IMUL: case Constants.INEG: case Constants.IOR: case Constants.IREM: case Constants.ISHL: case Constants.ISHR: case Constants.ISUB: case Constants.IUSHR: case Constants.IXOR: return Type.INT; case Constants.LADD: case Constants.LAND: case Constants.LDIV: case Constants.LMUL: case Constants.LNEG: case Constants.LOR: case Constants.LREM: case Constants.LSHL: case Constants.LSHR: case Constants.LSUB: case Constants.LUSHR: case Constants.LXOR: return Type.LONG; default: throw new ClassGenException('Unknown type ' + opcode); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.generic.ConversionInstruction.getType(ConstantPoolGen)
/** @return type associated with the instruction */ public Type getType(ConstantPoolGen cp) { switch(opcode) { case Constants.D2I: case Constants.F2I: case Constants.L2I: return Type.INT; case Constants.D2F: case Constants.I2F: case Constants.L2F: return Type.FLOAT; case Constants.D2L: case Constants.F2L: case Constants.I2L: return Type.LONG; case Constants.F2D: case Constants.I2D: case Constants.L2D: return Type.DOUBLE; case Constants.I2B: return Type.BYTE; case Constants.I2C: return Type.CHAR; case Constants.I2S: return Type.SHORT; default: throw new ClassGenException('Unknown type ' + opcode); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.bcel.internal.generic.ReturnInstruction.getType()
public Type getType() { switch(opcode) { case Constants.IRETURN: return Type.INT; case Constants.LRETURN: return Type.LONG; case Constants.FRETURN: return Type.FLOAT; case Constants.DRETURN: return Type.DOUBLE; case Constants.ARETURN: return Type.OBJECT; case Constants.RETURN: return Type.VOID; default: throw new ClassGenException('Unknown type ' + opcode); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
Comments
Post a Comment