test/tools/javac/annotations/typeAnnotations/failures/StaticFields.java

changeset 0
959103a6100f
child 2525
2eb010b6cb22
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/tools/javac/annotations/typeAnnotations/failures/StaticFields.java	Wed Apr 27 01:34:52 2016 +0800
     1.3 @@ -0,0 +1,27 @@
     1.4 +/*
     1.5 + * @test /nodynamiccopyright/
     1.6 + * @bug 6843077 8006775
     1.7 + * @summary static field access isn't a valid location
     1.8 + * @author Mahmood Ali
     1.9 + * @compile/fail/ref=StaticFields.out -XDrawDiagnostics StaticFields.java
    1.10 + */
    1.11 +import java.lang.annotation.*;
    1.12 +
    1.13 +class C {
    1.14 +  static int f;
    1.15 +  // static block
    1.16 +  static {
    1.17 +    @A C.f = 1;
    1.18 +  }
    1.19 +  // static ref
    1.20 +  int a = @A C.f;
    1.21 +  // static method
    1.22 +  static int f() { return @A C.f; }
    1.23 +  // main
    1.24 +  public static void main(String... args) {
    1.25 +    int a = @A C.f;
    1.26 +  }
    1.27 +}
    1.28 +
    1.29 +@Target(ElementType.TYPE_USE)
    1.30 +@interface A { }

mercurial