} catch (Exception e) {
}
}
public void testIllegalDebugLabelUse() throws IOException {
ClassReader cr = new ClassReader("java.lang.Object");
ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_MAXS);
ClassVisitor cv = new ClassAdapter(cw) {
@Override
public MethodVisitor visitMethod(
int access,
String name,
String desc,
String signature,
String[] exceptions)
{
final MethodVisitor next = cv.visitMethod(access,
name,
desc,
signature,
exceptions);
if (next == null) {
return next;
}
return new MethodAdapter(new CheckMethodAdapter(next)) {
private Label entryLabel = null;
@Override
public void visitLabel(Label label) {
if (entryLabel == null) {
entryLabel = label;
}
mv.visitLabel(label);
}
@Override
public void visitMaxs(int maxStack, int maxLocals) {
Label unwindhandler = new Label();
mv.visitLabel(unwindhandler);
mv.visitInsn(Opcodes.ATHROW); // rethrow
mv.visitTryCatchBlock(entryLabel,
unwindhandler,
unwindhandler,
null);
mv.visitMaxs(maxStack, maxLocals);
}
};
}
};
try {
cr.accept(cv, ClassReader.EXPAND_FRAMES);
fail();
} catch (Exception e) {
}
}