Wed, 23 Jan 2013 13:27:24 -0800
8006775: JSR 308: Compiler changes in JDK8
Reviewed-by: jjg
Contributed-by: mernst@cs.washington.edu, wmdietl@cs.washington.edu, mpapi@csail.mit.edu, mahmood@notnoop.com
1 /*
2 * @test /nodynamiccopyright/
3 * @bug 8006733 8006775
4 * @ignore
5 * @summary A static outer class cannot be annotated.
6 * @author Werner Dietl
7 * @compile/fail/ref=CantAnnotateStaticClass.out -XDrawDiagnostics CantAnnotateStaticClass.java
8 */
10 import java.util.List;
11 import java.lang.annotation.*;
13 class CantAnnotateStaticClass {
14 @Target(ElementType.TYPE_USE)
15 @interface A {}
17 static class Outer {
18 class Inner {}
19 }
21 // 8 errors:
22 @A Outer.Inner f1;
23 @A Outer.Inner f1r() { return null; }
24 void f1p(@A Outer.Inner p) { }
25 void f1c(Object o) {
26 Object l = (@A Outer.Inner) o;
27 }
29 List<@A Outer.Inner> f2;
30 List<@A Outer.Inner> f2r() { return null; }
31 void f2p(List<@A Outer.Inner> p) { }
32 void f2c(Object o) {
33 Object l = (List<@A Outer.Inner>) o;
34 }
36 // OK:
37 @A Outer g1;
38 List<@A Outer> g2;
39 Outer. @A Inner g3;
40 List<Outer. @A Inner> g4;
41 }