InstructionAdapter shall throw consistent exceptions
When api is below ASM5, InstructionAdapter.visitLdcInsn throws UnsupportedOperationException:
public void visitLdcInsn(final Object value) { if (api < Opcodes.ASM5 && (value instanceof Handle || (value instanceof Type && ((Type) value).getSort() == Type.METHOD))) { throw new UnsupportedOperationException("This feature requires ASM5"); }...
However, some other methods of this class throw different exceptions. For example, invokevirtual is as follows:
public void invokevirtual( final String owner, final String name, final String descriptor, final boolean isInterface) { if (api < Opcodes.ASM5) { if (isInterface) { throw new IllegalArgumentException("INVOKEVIRTUAL on interfaces require ASM 5"); } invokevirtual(owner, name, descriptor); return; } mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, owner, name, descriptor, isInterface); }
As a result, my code fails to catch the exception, and I have to analyze the message to determine the problem. Can ASM throw the identical exception for the same problem?