|
1 /* |
|
2 * @test /nodynamiccopyright/ |
|
3 * @bug 6843077 8006775 |
|
4 * @summary static field access isn't a valid location |
|
5 * @author Mahmood Ali |
|
6 * @compile/fail/ref=StaticFields.out -XDrawDiagnostics StaticFields.java |
|
7 */ |
|
8 import java.lang.annotation.*; |
|
9 |
|
10 class C { |
|
11 static int f; |
|
12 // static block |
|
13 static { |
|
14 @A C.f = 1; |
|
15 } |
|
16 // static ref |
|
17 int a = @A C.f; |
|
18 // static method |
|
19 static int f() { return @A C.f; } |
|
20 // main |
|
21 public static void main(String... args) { |
|
22 int a = @A C.f; |
|
23 } |
|
24 } |
|
25 |
|
26 @Target(ElementType.TYPE_USE) |
|
27 @interface A { } |