26 import java.lang.Class;
27 import java.lang.String;
28 import java.lang.System;
29 import java.lang.management.ManagementFactory;
30 import java.lang.management.RuntimeMXBean;
31 import java.util.ArrayList;
32 import java.util.List;
33 import java.util.concurrent.CyclicBarrier;
34 import java.util.regex.Matcher;
35 import java.util.regex.Pattern;
36 import java.lang.reflect.Field;
37 import java.lang.reflect.Modifier;
38 import sun.misc.Unsafe;
39 import jdk.internal.vm.annotation.Contended;
40
41 /*
42 * @test
43 * @bug 8014509
44 * @summary \@Contended: explicit default value behaves differently from the implicit value
45 *
46 * @modules java.base/sun.misc
47 * @run main/othervm -XX:-RestrictContended DefaultValue
48 */
49 public class DefaultValue {
50
51 private static final Unsafe U;
52 private static int ADDRESS_SIZE;
53 private static int HEADER_SIZE;
54
55 static {
56 // steal Unsafe
57 try {
58 Field unsafe = Unsafe.class.getDeclaredField("theUnsafe");
59 unsafe.setAccessible(true);
60 U = (Unsafe) unsafe.get(null);
61 } catch (NoSuchFieldException | IllegalAccessException e) {
62 throw new IllegalStateException(e);
63 }
64
65 // When running with CompressedOops on 64-bit platform, the address size
66 // reported by Unsafe is still 8, while the real reference fields are 4 bytes long.
|
26 import java.lang.Class;
27 import java.lang.String;
28 import java.lang.System;
29 import java.lang.management.ManagementFactory;
30 import java.lang.management.RuntimeMXBean;
31 import java.util.ArrayList;
32 import java.util.List;
33 import java.util.concurrent.CyclicBarrier;
34 import java.util.regex.Matcher;
35 import java.util.regex.Pattern;
36 import java.lang.reflect.Field;
37 import java.lang.reflect.Modifier;
38 import sun.misc.Unsafe;
39 import jdk.internal.vm.annotation.Contended;
40
41 /*
42 * @test
43 * @bug 8014509
44 * @summary \@Contended: explicit default value behaves differently from the implicit value
45 *
46 * @modules java.base/jdk.internal.vm.annotation
47 * @run main/othervm -XX:-RestrictContended DefaultValue
48 */
49 public class DefaultValue {
50
51 private static final Unsafe U;
52 private static int ADDRESS_SIZE;
53 private static int HEADER_SIZE;
54
55 static {
56 // steal Unsafe
57 try {
58 Field unsafe = Unsafe.class.getDeclaredField("theUnsafe");
59 unsafe.setAccessible(true);
60 U = (Unsafe) unsafe.get(null);
61 } catch (NoSuchFieldException | IllegalAccessException e) {
62 throw new IllegalStateException(e);
63 }
64
65 // When running with CompressedOops on 64-bit platform, the address size
66 // reported by Unsafe is still 8, while the real reference fields are 4 bytes long.
|