jdk
1/*
2* @test /nodynamiccopyright/
3* @bug 8254274 8258421
4* @summary lint should warn when an instance of a value based class is synchronized upon
5* @compile/fail/ref=ExternalAbuseOfVbc.out -XDrawDiagnostics -Werror -Xlint ExternalAbuseOfVbc.java
6* @compile/fail/ref=ExternalAbuseOfVbc.out -XDrawDiagnostics -Werror -Xlint:all ExternalAbuseOfVbc.java
7* @compile/fail/ref=ExternalAbuseOfVbc.out -XDrawDiagnostics -Werror -Xlint:synchronization ExternalAbuseOfVbc.java
8* @compile/fail/ref=ExternalAbuseOfVbc.out --release 16 -XDrawDiagnostics -Werror -Xlint:synchronization ExternalAbuseOfVbc.java
9* @compile/ref=LintModeOffAbuseOfVbc.out -XDrawDiagnostics -Werror -Xlint:-synchronization ExternalAbuseOfVbc.java
10*/
11
12public final class ExternalAbuseOfVbc {
13
14final Integer val = Integer.valueOf(42);
15final String ref = "String";
16
17void abuseVbc() {
18synchronized(ref) { // OK
19synchronized (val) { // WARN
20}
21}
22}
23}
24
25