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 /*
25 * @test
26 * @bug 8058744
27 * @summary Invalid pattern-matching of address computations in raw unsafe
28 * @library /testlibrary
29 * @modules java.base/sun.misc
30 * java.management
31 * @run main/othervm -Xbatch UnsafeRaw
32 */
33
34 import com.oracle.java.testlibrary.Utils;
35 import java.util.Random;
36
37 public class UnsafeRaw {
38 public static class Tests {
39 public static int int_index(sun.misc.Unsafe unsafe, long base, int index) throws Exception {
40 return unsafe.getInt(base + (index << 2));
41 }
42 public static int long_index(sun.misc.Unsafe unsafe, long base, long index) throws Exception {
43 return unsafe.getInt(base + (index << 2));
44 }
45 public static int int_index_back_ashift(sun.misc.Unsafe unsafe, long base, int index) throws Exception {
46 return unsafe.getInt(base + (index >> 2));
47 }
48 public static int int_index_back_lshift(sun.misc.Unsafe unsafe, long base, int index) throws Exception {
49 return unsafe.getInt(base + (index >>> 2));
50 }
51 public static int long_index_back_ashift(sun.misc.Unsafe unsafe, long base, long index) throws Exception {
52 return unsafe.getInt(base + (index >> 2));
53 }
54 public static int long_index_back_lshift(sun.misc.Unsafe unsafe, long base, long index) throws Exception {
|
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 /*
25 * @test
26 * @bug 8058744
27 * @summary Invalid pattern-matching of address computations in raw unsafe
28 * @library /testlibrary
29 * @modules java.base/sun.misc
30 * java.management
31 * @run main/othervm -Xbatch UnsafeRaw
32 */
33
34 import jdk.test.lib.Utils;
35 import java.util.Random;
36
37 public class UnsafeRaw {
38 public static class Tests {
39 public static int int_index(sun.misc.Unsafe unsafe, long base, int index) throws Exception {
40 return unsafe.getInt(base + (index << 2));
41 }
42 public static int long_index(sun.misc.Unsafe unsafe, long base, long index) throws Exception {
43 return unsafe.getInt(base + (index << 2));
44 }
45 public static int int_index_back_ashift(sun.misc.Unsafe unsafe, long base, int index) throws Exception {
46 return unsafe.getInt(base + (index >> 2));
47 }
48 public static int int_index_back_lshift(sun.misc.Unsafe unsafe, long base, int index) throws Exception {
49 return unsafe.getInt(base + (index >>> 2));
50 }
51 public static int long_index_back_ashift(sun.misc.Unsafe unsafe, long base, long index) throws Exception {
52 return unsafe.getInt(base + (index >> 2));
53 }
54 public static int long_index_back_lshift(sun.misc.Unsafe unsafe, long base, long index) throws Exception {
|