/** * Visits a try catch block. * * @param start * beginning of the exception handler's scope (inclusive). * @param end * end of the exception handler's scope (exclusive). * @param handler * beginning of the exception handler's code. * @param type * internal name of the type of exceptions handled by the * handler, or <tt>null</tt> to catch any exceptions (for * "finally" blocks). * @throws IllegalArgumentException * if one of the labels has already been visited by this visitor * (by the {@link #visitLabel visitLabel} method). */ public void visitTryCatchBlock(Label start, Label end, Label handler, String type) { if (mv != null) { mv.visitTryCatchBlock(start, end, handler, type); } }
@Override public void visitTryCatchBlock(final Label start, final Label end, final Label handler, final String type) { p.visitTryCatchBlock(start, end, handler, type); super.visitTryCatchBlock(start, end, handler, type); }
/** * Marks the start of an exception handler. * * @param start * beginning of the exception handler's scope (inclusive). * @param end * end of the exception handler's scope (exclusive). * @param exception * internal name of the type of exceptions handled by the * handler. */ public void catchException(final Label start, final Label end, final Type exception) { if (exception == null) { mv.visitTryCatchBlock(start, end, mark(), null); } else { mv.visitTryCatchBlock(start, end, mark(), exception.getInternalName()); } } }
/** * Makes the given visitor visit this try catch block. * * @param mv * a method visitor. */ public void accept(final MethodVisitor mv) { mv.visitTryCatchBlock(start.getLabel(), end.getLabel(), handler == null ? null : handler.getLabel(), type); int n = visibleTypeAnnotations == null ? 0 : visibleTypeAnnotations .size(); for (int i = 0; i < n; ++i) { TypeAnnotationNode an = visibleTypeAnnotations.get(i); an.accept(mv.visitTryCatchAnnotation(an.typeRef, an.typePath, an.desc, true)); } n = invisibleTypeAnnotations == null ? 0 : invisibleTypeAnnotations .size(); for (int i = 0; i < n; ++i) { TypeAnnotationNode an = invisibleTypeAnnotations.get(i); an.accept(mv.visitTryCatchAnnotation(an.typeRef, an.typePath, an.desc, false)); } } }
Label handler = readLabel(readUnsignedShort(u + 6), labels); String type = readUTF8(items[readUnsignedShort(u + 8)], c); mv.visitTryCatchBlock(start, end, handler, type); u += 8;