File: T4880220.java

package info (click to toggle)
libnb-javaparser-java 7.4-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch
  • size: 35,940 kB
  • ctags: 55,696
  • sloc: java: 264,137; xml: 2,781; sh: 1,135; makefile: 425
file content (43 lines) | stat: -rw-r--r-- 1,226 bytes parent folder | download | duplicates (16)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
 * @test /nodynamiccopyright/
 * @bug 4880220
 * @summary Add a warning when accessing a static method via an reference
 *
 * @compile/ref=T4880220.empty.out                                                   T4880220.java
 * @compile/ref=T4880220.warn.out       -XDrawDiagnostics         -Xlint:static      T4880220.java
 * @compile/ref=T4880220.warn.out       -XDrawDiagnostics         -Xlint:all         T4880220.java
 * @compile/ref=T4880220.empty.out      -XDrawDiagnostics         -Xlint:all,-static T4880220.java
 * @compile/ref=T4880220.error.out/fail -XDrawDiagnostics -Werror -Xlint:all         T4880220.java
 */

public class T4880220 {
    void m1() {
        int good_1 = C.m();
        int good_2 = C.f;
        int good_3 = C.x;

        C c = new C();
        int bad_inst_1 = c.m();
        int bad_inst_2 = c.f;
        int bad_inst_3 = c.x;

        int bad_expr_1 = c().m();
        int bad_expr_2 = c().f;
        int bad_expr_3 = c().x;
    }

    void m2() {
        Class<?> good_1 = C.class;
        Class<?> good_2 = C[].class;
    }

    C c() {
        return new C();
    }

    static class C {
        static int m() { return 0; }
        static int f;
        static final int x = 3;
    }
}