Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type-Use Annotations in Catch clause cause ArrayIndexOutOfBounds exception #116

Open
stephaniestroka opened this issue Oct 28, 2016 · 0 comments

Comments

@stephaniestroka
Copy link

stephaniestroka commented Oct 28, 2016

I ran into the following problem while trying to "retrolambdify" my code.

Error! Failed to run Retrolambda
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
    at java.util.ArrayList.rangeCheck(ArrayList.java:653)
    at java.util.ArrayList.get(ArrayList.java:429)
    at net.orfjackal.retrolambda.asm.tree.MethodNode.visitTryCatchAnnotation(MethodNode.java:550)
    at net.orfjackal.retrolambda.asm.MethodVisitor.visitTryCatchAnnotation(MethodVisitor.java:761)
    at net.orfjackal.retrolambda.asm.ClassReader.readTypeAnnotations(ClassReader.java:1641)
    at net.orfjackal.retrolambda.asm.ClassReader.readCode(ClassReader.java:1186)
    at net.orfjackal.retrolambda.asm.ClassReader.readMethod(ClassReader.java:1017)
    at net.orfjackal.retrolambda.asm.ClassReader.accept(ClassReader.java:693)
    at net.orfjackal.retrolambda.asm.ClassReader.accept(ClassReader.java:506)
    at net.orfjackal.retrolambda.Transformers.backportInterface(Transformers.java:64)
    at net.orfjackal.retrolambda.Retrolambda.run(Retrolambda.java:74)
    at net.orfjackal.retrolambda.Main.main(Main.java:26)

It is caused by the following code:

    public default Consumer<T> suppressExceptions(Consumer<? super Exception> handler) {
        return object -> {
            try {
                consume(object);
            } catch (@Nonnull Exception exception) {
                handler.consume(exception);
            }
        };
    }

If I remove the @nonnull annotation in the catch clause, retrolambda works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant