langtools/test/tools/javac/4880220/T4880220.java
author peterz
Fri, 28 May 2010 13:32:40 +0400
changeset 5594 3db39773da2e
parent 5002 12a9e8562200
permissions -rw-r--r--
6954231: SynthTextPaneUI.installUI() doesn't set component to opaque even if prop was not set by client progr Reviewed-by: alexp
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5002
12a9e8562200 4880220: Add a warning when accessing a static method via an reference
jjg
parents:
diff changeset
     1
/*
12a9e8562200 4880220: Add a warning when accessing a static method via an reference
jjg
parents:
diff changeset
     2
 * @test /nodynamiccopyright/
12a9e8562200 4880220: Add a warning when accessing a static method via an reference
jjg
parents:
diff changeset
     3
 * @bug 4880220
12a9e8562200 4880220: Add a warning when accessing a static method via an reference
jjg
parents:
diff changeset
     4
 * @summary Add a warning when accessing a static method via an reference
12a9e8562200 4880220: Add a warning when accessing a static method via an reference
jjg
parents:
diff changeset
     5
 *
12a9e8562200 4880220: Add a warning when accessing a static method via an reference
jjg
parents:
diff changeset
     6
 * @compile/ref=T4880220.empty.out                                                   T4880220.java
12a9e8562200 4880220: Add a warning when accessing a static method via an reference
jjg
parents:
diff changeset
     7
 * @compile/ref=T4880220.warn.out       -XDrawDiagnostics         -Xlint:static      T4880220.java
12a9e8562200 4880220: Add a warning when accessing a static method via an reference
jjg
parents:
diff changeset
     8
 * @compile/ref=T4880220.warn.out       -XDrawDiagnostics         -Xlint:all         T4880220.java
12a9e8562200 4880220: Add a warning when accessing a static method via an reference
jjg
parents:
diff changeset
     9
 * @compile/ref=T4880220.empty.out      -XDrawDiagnostics         -Xlint:all,-static T4880220.java
12a9e8562200 4880220: Add a warning when accessing a static method via an reference
jjg
parents:
diff changeset
    10
 * @compile/ref=T4880220.error.out/fail -XDrawDiagnostics -Werror -Xlint:all         T4880220.java
12a9e8562200 4880220: Add a warning when accessing a static method via an reference
jjg
parents:
diff changeset
    11
 */
12a9e8562200 4880220: Add a warning when accessing a static method via an reference
jjg
parents:
diff changeset
    12
12a9e8562200 4880220: Add a warning when accessing a static method via an reference
jjg
parents:
diff changeset
    13
public class T4880220 {
12a9e8562200 4880220: Add a warning when accessing a static method via an reference
jjg
parents:
diff changeset
    14
    void m1() {
12a9e8562200 4880220: Add a warning when accessing a static method via an reference
jjg
parents:
diff changeset
    15
        int good_1 = C.m();
12a9e8562200 4880220: Add a warning when accessing a static method via an reference
jjg
parents:
diff changeset
    16
        int good_2 = C.f;
12a9e8562200 4880220: Add a warning when accessing a static method via an reference
jjg
parents:
diff changeset
    17
        int good_3 = C.x;
12a9e8562200 4880220: Add a warning when accessing a static method via an reference
jjg
parents:
diff changeset
    18
12a9e8562200 4880220: Add a warning when accessing a static method via an reference
jjg
parents:
diff changeset
    19
        C c = new C();
12a9e8562200 4880220: Add a warning when accessing a static method via an reference
jjg
parents:
diff changeset
    20
        int bad_inst_1 = c.m();
12a9e8562200 4880220: Add a warning when accessing a static method via an reference
jjg
parents:
diff changeset
    21
        int bad_inst_2 = c.f;
12a9e8562200 4880220: Add a warning when accessing a static method via an reference
jjg
parents:
diff changeset
    22
        int bad_inst_3 = c.x;
12a9e8562200 4880220: Add a warning when accessing a static method via an reference
jjg
parents:
diff changeset
    23
12a9e8562200 4880220: Add a warning when accessing a static method via an reference
jjg
parents:
diff changeset
    24
        int bad_expr_1 = c().m();
12a9e8562200 4880220: Add a warning when accessing a static method via an reference
jjg
parents:
diff changeset
    25
        int bad_expr_2 = c().f;
12a9e8562200 4880220: Add a warning when accessing a static method via an reference
jjg
parents:
diff changeset
    26
        int bad_expr_3 = c().x;
12a9e8562200 4880220: Add a warning when accessing a static method via an reference
jjg
parents:
diff changeset
    27
    }
12a9e8562200 4880220: Add a warning when accessing a static method via an reference
jjg
parents:
diff changeset
    28
12a9e8562200 4880220: Add a warning when accessing a static method via an reference
jjg
parents:
diff changeset
    29
    void m2() {
12a9e8562200 4880220: Add a warning when accessing a static method via an reference
jjg
parents:
diff changeset
    30
        Class<?> good_1 = C.class;
12a9e8562200 4880220: Add a warning when accessing a static method via an reference
jjg
parents:
diff changeset
    31
        Class<?> good_2 = C[].class;
12a9e8562200 4880220: Add a warning when accessing a static method via an reference
jjg
parents:
diff changeset
    32
    }
12a9e8562200 4880220: Add a warning when accessing a static method via an reference
jjg
parents:
diff changeset
    33
12a9e8562200 4880220: Add a warning when accessing a static method via an reference
jjg
parents:
diff changeset
    34
    C c() {
12a9e8562200 4880220: Add a warning when accessing a static method via an reference
jjg
parents:
diff changeset
    35
        return new C();
12a9e8562200 4880220: Add a warning when accessing a static method via an reference
jjg
parents:
diff changeset
    36
    }
12a9e8562200 4880220: Add a warning when accessing a static method via an reference
jjg
parents:
diff changeset
    37
12a9e8562200 4880220: Add a warning when accessing a static method via an reference
jjg
parents:
diff changeset
    38
    static class C {
12a9e8562200 4880220: Add a warning when accessing a static method via an reference
jjg
parents:
diff changeset
    39
        static int m() { return 0; }
12a9e8562200 4880220: Add a warning when accessing a static method via an reference
jjg
parents:
diff changeset
    40
        static int f;
12a9e8562200 4880220: Add a warning when accessing a static method via an reference
jjg
parents:
diff changeset
    41
        static final int x = 3;
12a9e8562200 4880220: Add a warning when accessing a static method via an reference
jjg
parents:
diff changeset
    42
    }
12a9e8562200 4880220: Add a warning when accessing a static method via an reference
jjg
parents:
diff changeset
    43
}