< prev index next >

test/runtime/contended/Basic.java

Print this page
rev 10304 : [mq]: jake_pre_integ


  25 import java.io.InputStreamReader;
  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     8003985
  44  * @summary Support Contended Annotation - JEP 142
  45  * @modules java.base/sun.misc
  46  * @run main/othervm -XX:-RestrictContended Basic
  47  */
  48 public class Basic {
  49 
  50     private static final Unsafe U;
  51     private static int ADDRESS_SIZE;
  52     private static int HEADER_SIZE;
  53 
  54     static {
  55         // steal Unsafe
  56         try {
  57             Field unsafe = Unsafe.class.getDeclaredField("theUnsafe");
  58             unsafe.setAccessible(true);
  59             U = (Unsafe) unsafe.get(null);
  60         } catch (NoSuchFieldException | IllegalAccessException e) {
  61             throw new IllegalStateException(e);
  62         }
  63 
  64         // When running with CompressedOops on 64-bit platform, the address size
  65         // reported by Unsafe is still 8, while the real reference fields are 4 bytes long.




  25 import java.io.InputStreamReader;
  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     8003985
  44  * @summary Support Contended Annotation - JEP 142
  45  * @modules java.base/jdk.internal.vm.annotation
  46  * @run main/othervm -XX:-RestrictContended Basic
  47  */
  48 public class Basic {
  49 
  50     private static final Unsafe U;
  51     private static int ADDRESS_SIZE;
  52     private static int HEADER_SIZE;
  53 
  54     static {
  55         // steal Unsafe
  56         try {
  57             Field unsafe = Unsafe.class.getDeclaredField("theUnsafe");
  58             unsafe.setAccessible(true);
  59             U = (Unsafe) unsafe.get(null);
  60         } catch (NoSuchFieldException | IllegalAccessException e) {
  61             throw new IllegalStateException(e);
  62         }
  63 
  64         // When running with CompressedOops on 64-bit platform, the address size
  65         // reported by Unsafe is still 8, while the real reference fields are 4 bytes long.


< prev index next >