Commit b4debe87 authored by Remi Forax's avatar Remi Forax

Merge branch 'add-an-error-message-when-wrong-api-version-used' into 'master'

When ASM throws an UnsupportedOperationException, an error message should indicate the api level required

See merge request !214
parents cb2c88ab b10da01b
Pipeline #2823 passed with stage
in 6 minutes and 38 seconds
......@@ -637,10 +637,10 @@ public class InstructionAdapter extends MethodVisitor {
if (api < Opcodes.ASM5
&& (value instanceof Handle
|| (value instanceof Type && ((Type) value).getSort() == Type.METHOD))) {
throw new UnsupportedOperationException();
throw new UnsupportedOperationException("This feature requires ASM5");
}
if (api != Opcodes.ASM7 && value instanceof ConstantDynamic) {
throw new UnsupportedOperationException();
throw new UnsupportedOperationException("This feature requires ASM7");
}
if (value instanceof Integer) {
iconst((Integer) value);
......
......@@ -428,7 +428,7 @@ public class SerialVersionUIDAdder extends ClassVisitor {
try {
return MessageDigest.getInstance("SHA").digest(value);
} catch (Exception e) {
throw new UnsupportedOperationException(e.toString());
throw new UnsupportedOperationException(e);
}
}
......
......@@ -127,7 +127,7 @@ public abstract class ClassVisitor {
*/
public ModuleVisitor visitModule(final String name, final int access, final String version) {
if (api < Opcodes.ASM6) {
throw new UnsupportedOperationException();
throw new UnsupportedOperationException("This feature requires ASM6");
}
if (cv != null) {
return cv.visitModule(name, access, version);
......@@ -147,7 +147,7 @@ public abstract class ClassVisitor {
*/
public void visitNestHost(final String nestHost) {
if (api < Opcodes.ASM7) {
throw new UnsupportedOperationException();
throw new UnsupportedOperationException("This feature requires ASM7");
}
if (cv != null) {
cv.visitNestHost(nestHost);
......@@ -203,7 +203,7 @@ public abstract class ClassVisitor {
public AnnotationVisitor visitTypeAnnotation(
final int typeRef, final TypePath typePath, final String descriptor, final boolean visible) {
if (api < Opcodes.ASM5) {
throw new UnsupportedOperationException();
throw new UnsupportedOperationException("This feature requires ASM5");
}
if (cv != null) {
return cv.visitTypeAnnotation(typeRef, typePath, descriptor, visible);
......@@ -233,7 +233,7 @@ public abstract class ClassVisitor {
*/
public void visitNestMember(final String nestMember) {
if (api < Opcodes.ASM7) {
throw new UnsupportedOperationException();
throw new UnsupportedOperationException("This feature requires ASM7");
}
if (cv != null) {
cv.visitNestMember(nestMember);
......
......@@ -102,7 +102,7 @@ public abstract class FieldVisitor {
public AnnotationVisitor visitTypeAnnotation(
final int typeRef, final TypePath typePath, final String descriptor, final boolean visible) {
if (api < Opcodes.ASM5) {
throw new UnsupportedOperationException();
throw new UnsupportedOperationException("This feature requires ASM5");
}
if (fv != null) {
return fv.visitTypeAnnotation(typeRef, typePath, descriptor, visible);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment