1 /* 2 * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 import java.io.BufferedReader; 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 8015270 44 * @bug 8015493 45 * @summary \@Contended: fix multiple issues in the layout code 46 * 47 * @modules java.base/jdk.internal.vm.annotation 48 * @run main/othervm -XX:-RestrictContended -XX:ContendedPaddingWidth=128 -Xmx128m OopMaps 49 */ 50 public class OopMaps { 51 52 public static final int COUNT = 10000; 53 54 public static void main(String[] args) throws Exception { 55 Object o01 = new Object(); 56 Object o02 = new Object(); 57 Object o03 = new Object(); 58 Object o04 = new Object(); 59 Object o05 = new Object(); 60 Object o06 = new Object(); 61 Object o07 = new Object(); 62 Object o08 = new Object(); 63 Object o09 = new Object(); 64 Object o10 = new Object(); 65 Object o11 = new Object(); 66 Object o12 = new Object(); 67 Object o13 = new Object(); 68 Object o14 = new Object(); 69 70 R1[] rs = new R1[COUNT]; 71 72 for (int i = 0; i < COUNT; i++) { 73 R1 r1 = new R1(); 74 r1.o01 = o01; 75 r1.o02 = o02; 76 r1.o03 = o03; 77 r1.o04 = o04; 78 r1.o05 = o05; 79 r1.o06 = o06; 80 r1.o07 = o07; 81 r1.o08 = o08; 82 r1.o09 = o09; 83 r1.o10 = o10; 84 r1.o11 = o11; 85 r1.o12 = o12; 86 r1.o13 = o13; 87 r1.o14 = o14; 88 r1.i1 = 1; 89 r1.i2 = 2; 90 r1.i3 = 3; 91 r1.i4 = 4; 92 rs[i] = r1; 93 } 94 95 System.gc(); 96 97 for (int i = 0; i < COUNT; i++) { 98 R1 r1 = rs[i]; 99 if (r1.o01 != o01) throw new Error("Test Error: o01"); 100 if (r1.o02 != o02) throw new Error("Test Error: o02"); 101 if (r1.o03 != o03) throw new Error("Test Error: o03"); 102 if (r1.o04 != o04) throw new Error("Test Error: o04"); 103 if (r1.o05 != o05) throw new Error("Test Error: o05"); 104 if (r1.o06 != o06) throw new Error("Test Error: o06"); 105 if (r1.o07 != o07) throw new Error("Test Error: o07"); 106 if (r1.o08 != o08) throw new Error("Test Error: o08"); 107 if (r1.o09 != o09) throw new Error("Test Error: o09"); 108 if (r1.o10 != o10) throw new Error("Test Error: o10"); 109 if (r1.o11 != o11) throw new Error("Test Error: o11"); 110 if (r1.o12 != o12) throw new Error("Test Error: o12"); 111 if (r1.o13 != o13) throw new Error("Test Error: o13"); 112 if (r1.o14 != o14) throw new Error("Test Error: o14"); 113 if (r1.i1 != 1) throw new Error("Test Error: i1"); 114 if (r1.i2 != 2) throw new Error("Test Error: i2"); 115 if (r1.i3 != 3) throw new Error("Test Error: i3"); 116 if (r1.i4 != 4) throw new Error("Test Error: i4"); 117 } 118 } 119 120 public static class R0 { 121 int i1; 122 int i2; 123 124 Object o01; 125 Object o02; 126 127 @Contended 128 Object o03; 129 130 @Contended 131 Object o04; 132 133 @Contended 134 Object o05; 135 136 @Contended 137 Object o06; 138 139 @Contended 140 Object o07; 141 } 142 143 public static class R1 extends R0 { 144 int i3; 145 int i4; 146 147 Object o08; 148 Object o09; 149 150 @Contended 151 Object o10; 152 153 @Contended 154 Object o11; 155 156 @Contended 157 Object o12; 158 159 @Contended 160 Object o13; 161 162 @Contended 163 Object o14; 164 } 165 166 } 167