Test fails with AssertionError

Werner Dietl wdietl at gmail.com
Tue Apr 2 18:49:29 PDT 2013


Hi Steve,

I undid a bad change that I had pushed a few days ago.
CombinationsTargetTest3 should pass again.

Thanks for the T8009360b, which also passes. However, I noticed that
it produces output like this:
ClassWriter: Position UNKNOWN in type annotation: @A

which usually means the annotation is not present in the bytecode.
This only seems to happen for annotations on a type parameter or type
parameter bound of a method in an inner class within an anonymous
class. Very strange and I'm still looking for how to fix this.

Could you easily make a version of a test like T8009360b that also
ensures that the bytecode is correct and that the annotations
positions are set correctly? One simple change is to use:

@compile/ref=T8009360b.out T8009360b.java

- with an empty .out file - to ensure the warning is not generated.
However, this doesn't ensure that the type annotations are all in the
correct positions.

Thanks,
cu, WMD.


On Mon, Apr 1, 2013 at 5:13 PM, Steve Sides <steve.sides at oracle.com> wrote:
> On 4/1/2013 2:08 PM, Werner Dietl wrote:
>>
>> On Mon, Apr 1, 2013 at 2:01 PM, Steve Sides<steve.sides at oracle.com>
>> wrote:
>>>
>>> I don't have any for lambda and repeated annotations, other than the one
>>> noted (...Test3).
>>> CombinationsTargetTest3.java had been passing for a while, then it failed
>>> last night (not on a repeated annotation scenario).
>>
>> Ok, I'll work on making CombinationsTargetTest3 passing again.
>
> Interesting. I was sure that the T80093670.java as first submitted elicited
> the AssertionError. Then I saw it passing and added a couple extra lines to
> the test to get the AssertionError again. Now I see that is passing (again),
> but the same AssertionError happens with a different test case.
> When you run CombinationsTargetTest3, the .jtr file contains the small test
> case to reproduce.
>
>
>>
>>> I have one which tests some anonymous and inner classes (not lambda
>>> though),
>>> but it ran across the repeated annotation bugs too often and I did not
>>> put
>>> it back, but reported the bugs separately.
>>
>> I think I had fixed and included all these tests.
>> Can we somehow include these tests without repeated annotations? It
>> would be so much easier to keep track of whether everything still
>> works or not.
>
> Taking a second look, I could exclude the repeating scenarios, but since
> they are inner and anonymous classes, this current AssertionError block most
> tests cases.  The original was an anonyous class, the second an inner
> interface which means of course this
> class Test1 {
>     class Inner {
>          @A @B String i_odata1 = "test";
>     }
> }
> also fails. The whole test is anonymous and inner class members so it was
> difficult to complete my expected results.
> I put a compile only version of a generated test (with no repeating
> annotations) here:
> http://cr.openjdk.java.net/~ssides/tests/T8009360b.java
> That at least covers the usages for which there will be repeating
> annotations and covers the AssertionError cases.
>
> -steve
>
>
>> Thanks,
>> cu, WMD.
>>
>>> -steve
>>>
>>>
>>> On 4/1/2013 1:50 PM, Werner Dietl wrote:
>>>>
>>>> Thanks for the info, I'll look into this.
>>>> For me failures/T8009360.java is passing and I had ignored
>>>> classfile/CombinationsTargetTest3.java because of all the repeated
>>>> type annotations failures.
>>>> I'll add a separate test case for this.
>>>>
>>>> Are there any outstanding tests from you that I haven't included in
>>>> the repository yet? Do you have more tests for lambda and anonymous
>>>> classes?
>>>>
>>>> cu, WMD.
>>>>
>>>> On Mon, Apr 1, 2013 at 1:43 PM, Steve Sides<steve.sides at oracle.com>
>>>> wrote:
>>>>>
>>>>> Looking at today's nihgtly testing, I see the AssertionError reported
>>>>> in
>>>>> bug
>>>>> 8009360 (test
>>>>> tools/javac/annotations/typeAnnotations/failures/T8009360.java),
>>>>> now shows up in a testcase from
>>>>>
>>>>>
>>>>> tools/javac/annotations/typeAnnotations/classfile/CombinationsTargetTest3.java.
>>>>> The test case is:
>>>>>
>>>>> // src9: type annotations on static method of interface
>>>>> class Test17{
>>>>>     interface I  {
>>>>>       static @A @B String m() { @A @B String ret = "I.m"; return ret; }
>>>>>     }
>>>>> }
>>>>>
>>>>> @Retention(CLASS)
>>>>>
>>>>>
>>>>> @Target({TYPE_USE,TYPE,FIELD,METHOD,PARAMETER,CONSTRUCTOR,LOCAL_VARIABLE})
>>>>> @Repeatable( AC.class ) @interface A { }
>>>>> @Retention(CLASS)
>>>>>
>>>>>
>>>>> @Target({TYPE_USE,TYPE,FIELD,METHOD,PARAMETER,CONSTRUCTOR,LOCAL_VARIABLE})
>>>>> @interface AC { A[] value(); }
>>>>> @Retention(CLASS)
>>>>>
>>>>>
>>>>> @Target({TYPE_USE,TYPE,FIELD,METHOD,PARAMETER,CONSTRUCTOR,LOCAL_VARIABLE})
>>>>> @Repeatable( BC.class ) @interface B { }
>>>>> @Retention(CLASS)
>>>>>
>>>>>
>>>>> @Target({TYPE_USE,TYPE,FIELD,METHOD,PARAMETER,CONSTRUCTOR,LOCAL_VARIABLE})
>>>>> @interface BC { B[] value(); }
>>>>>
>>>>>
>>>>> This test had been passing up through 3/29(doesn't look like we got a
>>>>> build
>>>>> and test on 3/30).
>>>>> Contents of log file from the test is below
>>>>>
>>>>> -steve
>>>>>
>>>>>
>>>>> 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: Can't annotate already annotated type: (@A, at B
>>>>> ::
>>>>> java.lang.String); adding: @A, at B
>>>>>          at com.sun.tools.javac.util.Assert.error(Assert.java:133)
>>>>>          at com.sun.tools.javac.util.Assert.check(Assert.java:94)
>>>>>          at
>>>>> com.sun.tools.javac.code.Type$AnnotatedType.<init>(Type.java:1591)
>>>>>          at
>>>>>
>>>>>
>>>>> com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions$1.visitAnnotatedType(TypeAnnotations.java:518)
>>>>>          at
>>>>>
>>>>>
>>>>> com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions$1.visitAnnotatedType(TypeAnnotations.java:497)
>>>>>          at
>>>>> com.sun.tools.javac.code.Type$AnnotatedType.accept(Type.java:1628)
>>>>>          at
>>>>>
>>>>>
>>>>> com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.typeWithAnnotations(TypeAnnotations.java:577)
>>>>>          at
>>>>>
>>>>>
>>>>> com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.typeWithAnnotations(TypeAnnotations.java:461)
>>>>>          at
>>>>>
>>>>>
>>>>> com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.separateAnnotationsKinds(TypeAnnotations.java:291)
>>>>>          at
>>>>>
>>>>>
>>>>> com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.visitMethodDef(TypeAnnotations.java:985)
>>>>>          at
>>>>> com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:770)
>>>>>          at
>>>>> com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
>>>>>          at
>>>>>
>>>>>
>>>>> com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.scan(TypeAnnotations.java:233)
>>>>>          at
>>>>> com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:57)
>>>>>          at
>>>>>
>>>>>
>>>>> com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.visitClassDef(TypeAnnotations.java:959)
>>>>>          at
>>>>> com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:685)
>>>>>          at
>>>>> com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
>>>>>          at
>>>>>
>>>>>
>>>>> com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.scan(TypeAnnotations.java:233)
>>>>>          at
>>>>>
>>>>>
>>>>> com.sun.tools.javac.code.TypeAnnotations$1.enterAnnotation(TypeAnnotations.java:96)
>>>>>          at com.sun.tools.javac.comp.Annotate.flush(Annotate.java:140)
>>>>>          at
>>>>> com.sun.tools.javac.comp.Annotate.enterDone(Annotate.java:123)
>>>>>          at com.sun.tools.javac.comp.Enter.complete(Enter.java:514)
>>>>>          at com.sun.tools.javac.comp.Enter.main(Enter.java:473)
>>>>>          at
>>>>> com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:990)
>>>>>          at
>>>>> com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:865)
>>>>>          at com.sun.tools.javac.main.Main.compile(Main.java:519)
>>>>>          at com.sun.tools.javac.main.Main.compile(Main.java:376)
>>>>>          at com.sun.tools.javac.main.Main.compile(Main.java:365)
>>>>>          at com.sun.tools.javac.main.Main.compile(Main.java:356)
>>>>>          at com.sun.tools.javac.Main.compile(Main.java:77)
>>>>>          at ClassfileTestHelper.compile(ClassfileTestHelper.java:50)
>>>>>          at
>>>>> CombinationsTargetTest3.test(CombinationsTargetTest3.java:192)
>>>>>          at
>>>>> CombinationsTargetTest3.run(CombinationsTargetTest3.java:133)
>>>>>          at
>>>>> CombinationsTargetTest3.main(CombinationsTargetTest3.java:105)
>>>>>          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:487)
>>>>>          at
>>>>>
>>>>>
>>>>> com.sun.javatest.regtest.MainAction$SameVMRunnable.run(MainAction.java:706)
>>>>>          at java.lang.Thread.run(Thread.java:722)
>>>>> fail compile. Source:
>>>>> import java.lang.annotation.*;
>>>>> import static java.lang.annotation.RetentionPolicy.*;
>>>>> import static java.lang.annotation.ElementType.*;
>>>>> import java.util.List;
>>>>> import java.util.ArrayList;
>>>>>
>>>>> // src9: type annotations on static method of interface
>>>>> class Test17{
>>>>>     interface I  {
>>>>>       static @A @B String m() { @A @B String ret = "I.m"; return ret; }
>>>>>     }
>>>>> }
>>>>>
>>>>> @Retention(CLASS)
>>>>>
>>>>>
>>>>> @Target({TYPE_USE,TYPE,FIELD,METHOD,PARAMETER,CONSTRUCTOR,LOCAL_VARIABLE})
>>>>> @Repeatable( AC.class ) @interface A { }
>>>>> @Retention(CLASS)
>>>>>
>>>>>
>>>>> @Target({TYPE_USE,TYPE,FIELD,METHOD,PARAMETER,CONSTRUCTOR,LOCAL_VARIABLE})
>>>>> @interface AC { A[] value(); }
>>>>> @Retention(CLASS)
>>>>>
>>>>>
>>>>> @Target({TYPE_USE,TYPE,FIELD,METHOD,PARAMETER,CONSTRUCTOR,LOCAL_VARIABLE})
>>>>> @Repeatable( BC.class ) @interface B { }
>>>>> @Retention(CLASS)
>>>>>
>>>>>
>>>>> @Target({TYPE_USE,TYPE,FIELD,METHOD,PARAMETER,CONSTRUCTOR,LOCAL_VARIABLE})
>>>>> @interface BC { B[] value(); }
>>>>> @Retention(CLASS)
>>>>>
>>>>>
>>>>> @Target({TYPE_USE,TYPE_PARAMETER,TYPE,FIELD,METHOD,PARAMETER,CONSTRUCTOR,LOCAL_VARIABLE})
>>>>> @Repeatable(DC.class) @interface D { }
>>>>> @Retention(CLASS)
>>>>>
>>>>>
>>>>> @Target({TYPE_USE,TYPE_PARAMETER,TYPE,FIELD,METHOD,PARAMETER,CONSTRUCTOR,LOCAL_VARIABLE})
>>>>> @interface DC { D[] value(); }
>>>>>
>>>>> java.lang.Error: compilation failed. rc=4
>>>>>          at ClassfileTestHelper.compile(ClassfileTestHelper.java:53)
>>>>>          at
>>>>> CombinationsTargetTest3.test(CombinationsTargetTest3.java:192)
>>>>>          at
>>>>> CombinationsTargetTest3.run(CombinationsTargetTest3.java:133)
>>>>>          at
>>>>> CombinationsTargetTest3.main(CombinationsTargetTest3.java:105)
>>>>>          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:487)
>>>>>          at
>>>>>
>>>>>
>>>>> com.sun.javatest.regtest.MainAction$SameVMRunnable.run(MainAction.java:706)
>>>>>          at java.lang.Thread.run(Thread.java:722)
>>>>>
>>>>> JavaTest Message: Test threw exception: java.lang.Error
>>>>> JavaTest Message: shutting down test
>>>>>
>>>>> result: Failed. Execution failed: `main' threw exception:
>>>>> java.lang.Error:
>>>>> compilation failed. rc=4
>>>>>
>>>>>
>>>>> test result: Failed. Execution failed: `main' threw exception:
>>>>> java.lang.Error: compilation failed. rc=4
>>>>
>>>>
>>>>
>>
>>
>



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


More information about the type-annotations-dev mailing list