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

/*
 * @test /nodynamiccopyright/
 * @bug 8027262 8027888
 * @summary A class expression cannot be annotated.
 * @compile/fail/ref=AnnotatedClassExpr.out -XDrawDiagnostics AnnotatedClassExpr.java
 */
import java.lang.annotation.*;
import java.util.List;

class AnnotatedClassExpr {
  static void main() {
    Object o1 = @A int.class;
    o1 = @A int [] . class;
    o1 = int @A [] . class;
    o1 = int [] @A [] . class;
    o1 = AnnotatedClassExpr @A [] .class;
    o1 = @A AnnotatedClassExpr @A [] .class;
    o1 = @A AnnotatedClassExpr.class;
  }
}

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