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 annotation on exception parameter bug #344

Closed
GoogleCodeExporter opened this issue Jul 3, 2015 · 2 comments
Closed

Type annotation on exception parameter bug #344

GoogleCodeExporter opened this issue Jul 3, 2015 · 2 comments
Labels

Comments

@GoogleCodeExporter
Copy link

Compile the code below using the Nullness checker throws an exception asking to 
report a bug, but it should instead compile without warnings:

import org.checkerframework.checker.nullness.qual.*;

public class Test {
    public void foo() {
        try {
            return;
        } catch (@NonNull Exception e) {
        }
    }
}

This test passes by removing the @NonNull annotation or by removing the return 
call in the try block.

The exception can be seen below:
An exception has occurred in the compiler (1.8.0-jsr308-1.8.4). Please report 
this bug so we can fix it.  For instructions, see 
http://types.cs.washington.edu/checker-framework/current/README-jsr308.html#repo
rting-bugs .  Thank you.
java.lang.AssertionError: Could not find exception index for type annotation 
@org.checkerframework.checker.nullness.qual.NonNull on exception parameter
    at com.sun.tools.javac.util.Assert.error(Assert.java:133)
    at com.sun.tools.javac.jvm.Code.fillExceptionParameterPositions(Code.java:2154)
    at com.sun.tools.javac.jvm.Gen.genMethod(Gen.java:1075)
    at com.sun.tools.javac.jvm.Gen.visitMethodDef(Gen.java:983)
    at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:812)
    at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:726)
    at com.sun.tools.javac.jvm.Gen.genClass(Gen.java:2516)
    at com.sun.tools.javac.main.JavaCompiler.genCode(JavaCompiler.java:732)
    at com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1566)
    at com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1530)
    at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:884)
    at com.sun.tools.javac.main.Main.compile(Main.java:526)
    at com.sun.tools.javac.main.Main.compile(Main.java:381)
    at com.sun.tools.javac.main.Main.compile(Main.java:370)
    at com.sun.tools.javac.main.Main.compile(Main.java:361)
    at com.sun.tools.javac.Main.compile(Main.java:56)
    at com.sun.tools.javac.Main.main(Main.java:42)


The link to report a bug 
(http://types.cs.washington.edu/checker-framework/current/README-jsr308.html#rep
orting-bugs) is also broken.

Original issue reported on code.google.com by pbsf...@gmail.com on 7 Aug 2014 at 8:29

@GoogleCodeExporter
Copy link
Author

Thanks for the bug report!
This is a langtools bug and not caused by the Checker Framework.
Minimal test case that crashes jdk9 javac:

import java.lang.annotation.*;

class TestIssue344 {
    public void foo() {
        try {
            return;
        } catch (@TA Exception e) {
        }
    }
}

@Target(ElementType.TYPE_USE)
@interface TA {}

Note that this test works with jdk8 javac and if TA is a declaration annotation.
There were some big type annotation refactorings in jdk9 and something broke. 
Thanks for finding this!
I'll file a bug report.

Original comment by wdi...@gmail.com on 8 Aug 2014 at 3:19

  • Changed state: Accepted

@GoogleCodeExporter
Copy link
Author

I reported the bug on a compiler mailing list.
I've fixed the URL for the bug reporting instructions.

Original comment by wdi...@gmail.com on 9 Aug 2014 at 5:22

  • Changed state: Fixed

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

No branches or pull requests

2 participants