hotspot/test/runtime/8001071/Test8001071.java
author kvn
Mon, 01 Jul 2013 12:22:34 -0700
changeset 18503 9b63bbd77921
permissions -rw-r--r--
8006629: NEED_TEST: need test for JDK-8001071 Summary: added regression test Reviewed-by: kvn, coleenp Contributed-by: Filipp Zhinkin <filipp.zhinkin@oracle.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
18503
9b63bbd77921 8006629: NEED_TEST: need test for JDK-8001071
kvn
parents:
diff changeset
     1
/*
9b63bbd77921 8006629: NEED_TEST: need test for JDK-8001071
kvn
parents:
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
9b63bbd77921 8006629: NEED_TEST: need test for JDK-8001071
kvn
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9b63bbd77921 8006629: NEED_TEST: need test for JDK-8001071
kvn
parents:
diff changeset
     4
 *
9b63bbd77921 8006629: NEED_TEST: need test for JDK-8001071
kvn
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
9b63bbd77921 8006629: NEED_TEST: need test for JDK-8001071
kvn
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
9b63bbd77921 8006629: NEED_TEST: need test for JDK-8001071
kvn
parents:
diff changeset
     7
 * published by the Free Software Foundation.
9b63bbd77921 8006629: NEED_TEST: need test for JDK-8001071
kvn
parents:
diff changeset
     8
 *
9b63bbd77921 8006629: NEED_TEST: need test for JDK-8001071
kvn
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
9b63bbd77921 8006629: NEED_TEST: need test for JDK-8001071
kvn
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9b63bbd77921 8006629: NEED_TEST: need test for JDK-8001071
kvn
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
9b63bbd77921 8006629: NEED_TEST: need test for JDK-8001071
kvn
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
9b63bbd77921 8006629: NEED_TEST: need test for JDK-8001071
kvn
parents:
diff changeset
    13
 * accompanied this code).
9b63bbd77921 8006629: NEED_TEST: need test for JDK-8001071
kvn
parents:
diff changeset
    14
 *
9b63bbd77921 8006629: NEED_TEST: need test for JDK-8001071
kvn
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
9b63bbd77921 8006629: NEED_TEST: need test for JDK-8001071
kvn
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
9b63bbd77921 8006629: NEED_TEST: need test for JDK-8001071
kvn
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9b63bbd77921 8006629: NEED_TEST: need test for JDK-8001071
kvn
parents:
diff changeset
    18
 *
9b63bbd77921 8006629: NEED_TEST: need test for JDK-8001071
kvn
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9b63bbd77921 8006629: NEED_TEST: need test for JDK-8001071
kvn
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
9b63bbd77921 8006629: NEED_TEST: need test for JDK-8001071
kvn
parents:
diff changeset
    21
 * questions.
9b63bbd77921 8006629: NEED_TEST: need test for JDK-8001071
kvn
parents:
diff changeset
    22
 */
9b63bbd77921 8006629: NEED_TEST: need test for JDK-8001071
kvn
parents:
diff changeset
    23
9b63bbd77921 8006629: NEED_TEST: need test for JDK-8001071
kvn
parents:
diff changeset
    24
import sun.misc.Unsafe;
9b63bbd77921 8006629: NEED_TEST: need test for JDK-8001071
kvn
parents:
diff changeset
    25
import java.lang.reflect.Field;
9b63bbd77921 8006629: NEED_TEST: need test for JDK-8001071
kvn
parents:
diff changeset
    26
9b63bbd77921 8006629: NEED_TEST: need test for JDK-8001071
kvn
parents:
diff changeset
    27
@SuppressWarnings("sunapi")
9b63bbd77921 8006629: NEED_TEST: need test for JDK-8001071
kvn
parents:
diff changeset
    28
public class Test8001071 {
9b63bbd77921 8006629: NEED_TEST: need test for JDK-8001071
kvn
parents:
diff changeset
    29
    public static Unsafe unsafe;
9b63bbd77921 8006629: NEED_TEST: need test for JDK-8001071
kvn
parents:
diff changeset
    30
9b63bbd77921 8006629: NEED_TEST: need test for JDK-8001071
kvn
parents:
diff changeset
    31
    static {
9b63bbd77921 8006629: NEED_TEST: need test for JDK-8001071
kvn
parents:
diff changeset
    32
        try {
9b63bbd77921 8006629: NEED_TEST: need test for JDK-8001071
kvn
parents:
diff changeset
    33
            Field f = Unsafe.class.getDeclaredField("theUnsafe");
9b63bbd77921 8006629: NEED_TEST: need test for JDK-8001071
kvn
parents:
diff changeset
    34
            f.setAccessible(true);
9b63bbd77921 8006629: NEED_TEST: need test for JDK-8001071
kvn
parents:
diff changeset
    35
            unsafe = (Unsafe) f.get(null);
9b63bbd77921 8006629: NEED_TEST: need test for JDK-8001071
kvn
parents:
diff changeset
    36
        } catch ( Exception e ) {
9b63bbd77921 8006629: NEED_TEST: need test for JDK-8001071
kvn
parents:
diff changeset
    37
            e.printStackTrace();
9b63bbd77921 8006629: NEED_TEST: need test for JDK-8001071
kvn
parents:
diff changeset
    38
        }
9b63bbd77921 8006629: NEED_TEST: need test for JDK-8001071
kvn
parents:
diff changeset
    39
    }
9b63bbd77921 8006629: NEED_TEST: need test for JDK-8001071
kvn
parents:
diff changeset
    40
9b63bbd77921 8006629: NEED_TEST: need test for JDK-8001071
kvn
parents:
diff changeset
    41
    public static void main(String args[]) {
9b63bbd77921 8006629: NEED_TEST: need test for JDK-8001071
kvn
parents:
diff changeset
    42
        unsafe.getObject(new Test8001071(), Short.MAX_VALUE);
9b63bbd77921 8006629: NEED_TEST: need test for JDK-8001071
kvn
parents:
diff changeset
    43
    }
9b63bbd77921 8006629: NEED_TEST: need test for JDK-8001071
kvn
parents:
diff changeset
    44
9b63bbd77921 8006629: NEED_TEST: need test for JDK-8001071
kvn
parents:
diff changeset
    45
}