roterdam / checker-framework

Automatically exported from code.google.com/p/checker-framework
Other
0 stars 0 forks source link

Type annotation on exception parameter bug #344

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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 commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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