langtools/test/tools/javac/annotations/typeAnnotations/failures/AnnotatedClassExpr.java
author jlahoda
Tue, 13 Jan 2015 10:36:41 +0100
changeset 28454 63c31d7de8f6
parent 24895 dd091d389fbf
permissions -rw-r--r--
8027888: javac wrongly allows annotations in array-typed class literals Summary: Compiler incorrectly accepts type annotations on array-typed class literals. Reviewed-by: jlahoda, jfranck Contributed-by: srikanth.adayapalam@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24895
dd091d389fbf 8027262: Determine location for type annotations earlier in compiler pipeline
emc
parents:
diff changeset
     1
/*
dd091d389fbf 8027262: Determine location for type annotations earlier in compiler pipeline
emc
parents:
diff changeset
     2
 * @test /nodynamiccopyright/
28454
63c31d7de8f6 8027888: javac wrongly allows annotations in array-typed class literals
jlahoda
parents: 24895
diff changeset
     3
 * @bug 8027262 8027888
24895
dd091d389fbf 8027262: Determine location for type annotations earlier in compiler pipeline
emc
parents:
diff changeset
     4
 * @summary A class expression cannot be annotated.
dd091d389fbf 8027262: Determine location for type annotations earlier in compiler pipeline
emc
parents:
diff changeset
     5
 * @compile/fail/ref=AnnotatedClassExpr.out -XDrawDiagnostics AnnotatedClassExpr.java
dd091d389fbf 8027262: Determine location for type annotations earlier in compiler pipeline
emc
parents:
diff changeset
     6
 */
dd091d389fbf 8027262: Determine location for type annotations earlier in compiler pipeline
emc
parents:
diff changeset
     7
import java.lang.annotation.*;
dd091d389fbf 8027262: Determine location for type annotations earlier in compiler pipeline
emc
parents:
diff changeset
     8
import java.util.List;
dd091d389fbf 8027262: Determine location for type annotations earlier in compiler pipeline
emc
parents:
diff changeset
     9
dd091d389fbf 8027262: Determine location for type annotations earlier in compiler pipeline
emc
parents:
diff changeset
    10
class AnnotatedClassExpr {
dd091d389fbf 8027262: Determine location for type annotations earlier in compiler pipeline
emc
parents:
diff changeset
    11
  static void main() {
dd091d389fbf 8027262: Determine location for type annotations earlier in compiler pipeline
emc
parents:
diff changeset
    12
    Object o1 = @A int.class;
28454
63c31d7de8f6 8027888: javac wrongly allows annotations in array-typed class literals
jlahoda
parents: 24895
diff changeset
    13
    o1 = @A int [] . class;
63c31d7de8f6 8027888: javac wrongly allows annotations in array-typed class literals
jlahoda
parents: 24895
diff changeset
    14
    o1 = int @A [] . class;
63c31d7de8f6 8027888: javac wrongly allows annotations in array-typed class literals
jlahoda
parents: 24895
diff changeset
    15
    o1 = int [] @A [] . class;
63c31d7de8f6 8027888: javac wrongly allows annotations in array-typed class literals
jlahoda
parents: 24895
diff changeset
    16
    o1 = AnnotatedClassExpr @A [] .class;
63c31d7de8f6 8027888: javac wrongly allows annotations in array-typed class literals
jlahoda
parents: 24895
diff changeset
    17
    o1 = @A AnnotatedClassExpr @A [] .class;
63c31d7de8f6 8027888: javac wrongly allows annotations in array-typed class literals
jlahoda
parents: 24895
diff changeset
    18
    o1 = @A AnnotatedClassExpr.class;
24895
dd091d389fbf 8027262: Determine location for type annotations earlier in compiler pipeline
emc
parents:
diff changeset
    19
  }
dd091d389fbf 8027262: Determine location for type annotations earlier in compiler pipeline
emc
parents:
diff changeset
    20
}
dd091d389fbf 8027262: Determine location for type annotations earlier in compiler pipeline
emc
parents:
diff changeset
    21
dd091d389fbf 8027262: Determine location for type annotations earlier in compiler pipeline
emc
parents:
diff changeset
    22
@Target(ElementType.TYPE_USE)
dd091d389fbf 8027262: Determine location for type annotations earlier in compiler pipeline
emc
parents:
diff changeset
    23
@interface A { }