Test.java revision 2840:84849fdb360b
1/**@test /nodynamiccopyright/
2 * @compile/fail/ref=Test.out -Xplugin:coding_rules -XDrawDiagnostics Test.java
3 */
4
5import com.sun.tools.javac.util.Assert;
6
7public class Test {
8
9    String v;
10
11    public void check1(String value) {
12        Assert.check(value.trim().length() > 0, "value=" + value); //fail
13    }
14    public void check2(String value) {
15        Assert.check(value.trim().length() > 0, "value=" + "value"); //ok
16    }
17    public void check3(String value) {
18        Assert.check(value.trim().length() > 0, () -> "value=" + value); //ok
19    }
20    public void check4(String value) {
21        Assert.check(value.trim().length() > 0, value); //ok
22    }
23    public void check5(String value) {
24        Assert.check(value.trim().length() > 0, v); //ok
25    }
26    public void check6(String value) {
27        Assert.check(value.trim().length() > 0, () -> "value=" + "value"); //fail
28    }
29    public void check7(String value) {
30        Assert.check(value.trim().length() > 0, () -> value); //fail
31    }
32    public void check8(String value) {
33        Assert.check(value.trim().length() > 0, () -> v); //fail
34    }
35}
36