Type annotations in multicatch

Werner Dietl wdietl at gmail.com
Wed Jan 9 18:57:04 PST 2013


> I found another one. A type annotation on the 2nd type in a union type of a
> multicatch crashes javac.
> I attached a test case to this mail.  Basically, something like
>
>    catch(@A E1 | @A E2 e) {}
>
> causes javac to crash. The stack trace from the test is below.
> If I put it on the first one it is okay, but anything on the 2nd crashes.
> It will eventually show up as 8005959 on bugs.sun.com.

Thanks for this test case, Steve!

I can't reproduce the crash in my current setup, but I see why it
would happen in trunk.
It looks like there is only one exception table entry for a multicatch.
Therefore, it seems to me that only storing the exception table index
is not enough to distinguish between multiple annotations in a
multicatch.
Does the JSR 308 spec need some addition in Sec. 3.3.8? Or am I not
looking at the exception table correctly?

Thanks,
cu, WMD.


> stacktrace:
>
> An exception has occurred in the compiler (1.8.0-ea). Please file a bug at
> the Java Developer Connection (http://java.sun.com/webapps/bugreport) after
> checking the Bug Parade for duplicates. Include your program and the
> following diagnostic in your report. Thank you.
> java.lang.AssertionError: Unresolved frame: E1 | @C() E2 of kind: UNION_TYPE
>     Looking for tree: @C() E2
>         at com.sun.tools.javac.util.Assert.error(Assert.java:133)
>         at
> com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.resolveFrame(TypeAnnotations.java:582)
>         at
> com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.resolveFrame(TypeAnnotations.java:551)
>         at
> com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.findPosition(TypeAnnotations.java:763)
>         at
> com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.visitAnnotatedType(TypeAnnotations.java:701)
>         at
> com.sun.tools.javac.tree.JCTree$JCAnnotatedType.accept(JCTree.java:2281)
>         at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
>         at
> com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.scan(TypeAnnotations.java:92)
>         at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:57)
>         at
> com.sun.tools.javac.tree.TreeScanner.visitTypeUnion(TreeScanner.java:290)
>         at
> com.sun.tools.javac.tree.JCTree$JCTypeUnion.accept(JCTree.java:2072)
>         at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
>         at
> com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.scan(TypeAnnotations.java:92)
>         at
> com.sun.tools.javac.tree.TreeScanner.visitVarDef(TreeScanner.java:96)
>         at
> com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.visitVarDef(TypeAnnotations.java:694)
>         at
> com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:792)
>         at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
>         at
> com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.scan(TypeAnnotations.java:92)
>         at
> com.sun.tools.javac.tree.TreeScanner.visitCatch(TreeScanner.java:157)
>         at com.sun.tools.javac.tree.JCTree$JCCatch.accept(JCTree.java:1145)
>         at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
>         at
> com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.scan(TypeAnnotations.java:92)
>         at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:57)
>         at
> com.sun.tools.javac.tree.TreeScanner.visitTry(TreeScanner.java:152)
>         at com.sun.tools.javac.tree.JCTree$JCTry.accept(JCTree.java:1112)
>         at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
>         at
> com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.scan(TypeAnnotations.java:92)
>         at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:57)
>         at
> com.sun.tools.javac.tree.TreeScanner.visitBlock(TreeScanner.java:104)
>         at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:848)
>         at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
>         at
> com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.scan(TypeAnnotations.java:92)
>         at
> com.sun.tools.javac.tree.TreeScanner.visitMethodDef(TreeScanner.java:91)
>         at
> com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.visitMethodDef(TypeAnnotations.java:655)
>         at
> com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:735)
>         at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
>         at
> com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.scan(TypeAnnotations.java:92)
>         at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:57)
>         at
> com.sun.tools.javac.tree.TreeScanner.visitClassDef(TreeScanner.java:80)
>         at
> com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:650)
>         at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
>         at
> com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.scan(TypeAnnotations.java:92)
>         at
> com.sun.tools.javac.code.TypeAnnotations.organizeTypeAnnotations(TypeAnnotations.java:63)
>         at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:4036)
>         at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:3902)
>         at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:3836)
>         at com.sun.tools.javac.comp.Attr.attrib(Attr.java:3810)
>         at
> com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1254)
>         at
> com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:907)
>         at
> com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:866)
>         at com.sun.tools.javac.main.Main.compile(Main.java:506)
>         at com.sun.tools.javac.main.Main.compile(Main.java:365)
>         at com.sun.tools.javac.main.Main.compile(Main.java:354)
>         at com.sun.tools.javac.main.Main.compile(Main.java:345)
>         at com.sun.tools.javac.Main.compile(Main.java:94)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>         at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>         at java.lang.reflect.Method.invoke(Method.java:477)
>         at
> com.sun.javatest.regtest.RegressionCompileCommand.run(RegressionCompileCommand.java:247)
>         at
> com.sun.javatest.regtest.CompileAction.runCompile(CompileAction.java:556)
>         at
> com.sun.javatest.regtest.CompileAction.runSameJVM(CompileAction.java:395)
>         at
> com.sun.javatest.regtest.CompileAction.run(CompileAction.java:250)
>         at
> com.sun.javatest.regtest.RegressionScript.run(RegressionScript.java:146)
>         at com.sun.javatest.Script.run(Script.java:228)
>         at
> com.sun.javatest.DefaultTestRunner.runTest(DefaultTestRunner.java:174)
>         at
> com.sun.javatest.DefaultTestRunner.access$100(DefaultTestRunner.java:43)
>         at
> com.sun.javatest.DefaultTestRunner$1.run(DefaultTestRunner.java:66)
>
>
> On 1/9/2013 12:32 PM, Alex Buckley wrote:
>>
>> Hi Steve,
>>
>> Thanks for publishing this webrev. (And congrats on becoming an Author in
>> this project!)
>>
>> CombinationsTargetTest is pretty complicated. Could you please give a
>> description and examples of the combinations it generates?
>>
>> DeadCode, NewTypeArguments, TypeCasts, and Wildcards all use static fields
>> in their superclass (ClassfileTestHelper) to communicate expected results to
>> ClassfileTestHelper.countAnnotations(). Is it necessary to use static fields
>> for this purpose?
>>
>> 8005681 is interesting. You're saying that "new @Foo @Foo @Bar @Bar C()"
>> causes all four annotations to be dropped? Werner cannot access JBS, so it
>> would be helpful if you could send test cases to this list.
>>
>> Alex
>>
>> On 1/8/2013 3:45 PM, Steve Sides wrote:
>>>
>>> This test supercedes the test in the previous review request (which was
>>> via mail).
>>> http://cr.openjdk.java.net/~ssides/8005085/
>>>
>>> In writing a test for repeating type annotations I found it could cover
>>> several scenarios in one test, so this coverage
>>> mixed target types on type usages and type parameters as well as
>>> repeating type annotations in those usages.
>>>
>>> Due to http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=8005681 a few
>>> scenarios are commented out.
>>> In addition to any other changes or suggestions, we may want for that to
>>> be fixed so the whole test can be considered.
>>>
>>> This also include the previous refactoring of the classfile tests into a
>>> helper, ClassfileTestHelper.java.
>>> This makes the tests much simpler looking and easier to add new tests.
>>>
>>> I'd appreciate any comments or suggestions.
>>>
>>> -steve
>
>



-- 
http://www.google.com/profiles/wdietl


More information about the type-annotations-dev mailing list