/** * Add an exception handler to this code block. * * @param tryStart the first instruction of the try {} block * @param tryEnd the last instruction of the try {} block * @param handlerStart the first instruction of the catch {} block * @param catchType the type of exception being caught */ public ExceptionHandler addExceptionHandler(Instruction tryStart, Instruction tryEnd, Instruction handlerStart, String catchType) { ExceptionHandler handler = addExceptionHandler(); handler.setTryStart(tryStart); handler.setTryEnd(tryEnd); handler.setHandlerStart(handlerStart); handler.setCatch(catchType); return handler; }
/** * Add an exception handler to this code block. */ public ExceptionHandler addExceptionHandler() { ExceptionHandler handler = new ExceptionHandler(this); _handlers.add(handler); return handler; }
void write(DataOutput out) throws IOException { out.writeShort(getTryStartPc()); out.writeShort(getTryEndPc()); out.writeShort(getHandlerStartPc()); out.writeShort(getCatchIndex()); }
void read(DataInput in) throws IOException { setTryStart(in.readUnsignedShort()); setTryEnd(in.readUnsignedShort()); setHandlerStart(in.readUnsignedShort()); setCatchIndex(in.readUnsignedShort()); }
/** * Return the bytecode of the exception type; returns null for * catch-all clauses used to implement finally blocks. */ public BCClass getCatchBC() { String name = getCatchName(); if (name == null) return null; return getProject().loadClass(name, getClassLoader()); }
void read(ExceptionHandler orig) { _tryStart.setByteIndex(orig._tryStart.getByteIndex()); _tryEnd.setByteIndex(orig._tryEnd.getByteIndex()); _tryHandler.setByteIndex(orig._tryHandler.getByteIndex()); // done at a high level so that if the name isn't in our constant pool, // it will be added setCatch(orig.getCatchName()); }
public void setTryEnd(int end) { setTryEnd((Instruction) _owner.getInstruction(end).prev); }
/** * Return the {@link Class} of the exception type; returns null for * catch-all clauses used to implement finally blocks. */ public Class getCatchType() { String name = getCatchName(); if (name == null) return null; return Strings.toClass(name, getClassLoader()); }
/** * Return all exception handlers that catch the given exception type, * or an empty array if none. */ public ExceptionHandler[] getExceptionHandlers(String catchType) { catchType = getProject().getNameCache().getExternalForm(catchType, false); List matches = new LinkedList(); String type; ExceptionHandler[] handlers = getExceptionHandlers(); for (int i = 0; i < handlers.length; i++) { type = handlers[i].getCatchName(); if ((type == null && catchType == null) || (type != null && type.equals(catchType))) matches.add(handlers[i]); } return (ExceptionHandler[]) matches.toArray (new ExceptionHandler[matches.size()]); }
public void acceptVisit(BCVisitor visit) { visit.enterCode(this); Instruction ins; for (CodeEntry entry = _head.next; entry != _tail; entry = entry.next) { ins = (Instruction) entry; visit.enterInstruction(ins); ins.acceptVisit(visit); visit.exitInstruction(ins); } for (Iterator i = _handlers.iterator(); i.hasNext();) ((ExceptionHandler) i.next()).acceptVisit(visit); visitAttributes(visit); visit.exitCode(this); }
void read(DataInput in) throws IOException { setTryStart(in.readUnsignedShort()); setTryEnd(in.readUnsignedShort()); setHandlerStart(in.readUnsignedShort()); setCatchIndex(in.readUnsignedShort()); }
void read(ExceptionHandler orig) { _tryStart.setByteIndex(orig._tryStart.getByteIndex()); _tryEnd.setByteIndex(orig._tryEnd.getByteIndex()); _tryHandler.setByteIndex(orig._tryHandler.getByteIndex()); // done at a high level so that if the name isn't in our constant pool, // it will be added setCatch(orig.getCatchName()); }
/** * Return the bytecode of the exception type; returns null for * catch-all clauses used to implement finally blocks. */ public BCClass getCatchBC() { String name = getCatchName(); if (name == null) return null; return getProject().loadClass(name, getClassLoader()); }
public void setTryEnd(int end) { setTryEnd((Instruction) _owner.getInstruction(end).prev); }
/** * Return the {@link Class} of the exception type; returns null for * catch-all clauses used to implement finally blocks. */ public Class getCatchType() { String name = getCatchName(); if (name == null) return null; return Strings.toClass(name, getClassLoader()); }
/** * Return all exception handlers that catch the given exception type, * or an empty array if none. */ public ExceptionHandler[] getExceptionHandlers(String catchType) { catchType = getProject().getNameCache().getExternalForm(catchType, false); List matches = new LinkedList(); String type; ExceptionHandler[] handlers = getExceptionHandlers(); for (int i = 0; i < handlers.length; i++) { type = handlers[i].getCatchName(); if ((type == null && catchType == null) || (type != null && type.equals(catchType))) matches.add(handlers[i]); } return (ExceptionHandler[]) matches.toArray (new ExceptionHandler[matches.size()]); }
public void acceptVisit(BCVisitor visit) { visit.enterCode(this); Instruction ins; for (CodeEntry entry = _head.next; entry != _tail; entry = entry.next) { ins = (Instruction) entry; visit.enterInstruction(ins); ins.acceptVisit(visit); visit.exitInstruction(ins); } for (Iterator i = _handlers.iterator(); i.hasNext();) ((ExceptionHandler) i.next()).acceptVisit(visit); visitAttributes(visit); visit.exitCode(this); }
/** * Add an exception handler to this code block. * * @param tryStart the first instruction of the try {} block * @param tryEnd the last instruction of the try {} block * @param handlerStart the first instruction of the catch {} block * @param catchType the type of exception being caught */ public ExceptionHandler addExceptionHandler(Instruction tryStart, Instruction tryEnd, Instruction handlerStart, String catchType) { ExceptionHandler handler = addExceptionHandler(); handler.setTryStart(tryStart); handler.setTryEnd(tryEnd); handler.setHandlerStart(handlerStart); handler.setCatch(catchType); return handler; }