test/tools/javac/T4906100.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/T4906100.java	Wed Apr 27 01:34:52 2016 +0800
     1.3 @@ -0,0 +1,25 @@
     1.4 +/*
     1.5 + * @test  /nodynamiccopyright/
     1.6 + * @bug 4906100
     1.7 + * @summary detect empty statement after if
     1.8 + * @compile/ref=T4906100.out -XDrawDiagnostics -Xlint:empty T4906100.java
     1.9 + */
    1.10 +
    1.11 +class T4906100 {
    1.12 +    void f1(int a, int b) {
    1.13 +        if (a == b);
    1.14 +            System.out.println("a == b");
    1.15 +    }
    1.16 +
    1.17 +    @SuppressWarnings("empty")
    1.18 +    void f2(int a, int b) {
    1.19 +        if (a == b);
    1.20 +            System.out.println("a == b");
    1.21 +    }
    1.22 +
    1.23 +    // check that { } is not treated as an empty statement
    1.24 +    void f3(int a, int b) {
    1.25 +        if (a == b) { }
    1.26 +            System.out.println("a == b");
    1.27 +    }
    1.28 +}

mercurial