< prev index next >

test/compiler/intrinsics/unsafe/TestUnsafeUnalignedMismatchedAccesses.java

Print this page
rev 11557 : 8132919: use package in compiler tests
Reviewed-by: duke


  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 
  25 /**
  26  * @test
  27  * @bug 8136473
  28  * @summary Mismatched stores on same slice possible with Unsafe.Put*Unaligned methods
  29  * @modules java.base/jdk.internal.misc
  30  * @run main/othervm -XX:-UseOnStackReplacement -XX:-BackgroundCompilation TestUnsafeUnalignedMismatchedAccesses
  31  * @run main/othervm -XX:-UseOnStackReplacement -XX:-BackgroundCompilation -XX:+UnlockDiagnosticVMOptions -XX:-UseUnalignedAccesses TestUnsafeUnalignedMismatchedAccesses
  32  *





  33  */
  34 
  35 import java.lang.reflect.*;

  36 import jdk.internal.misc.Unsafe;
  37 


  38 public class TestUnsafeUnalignedMismatchedAccesses {
  39 
  40     private static final Unsafe UNSAFE;
  41 
  42     static {
  43         try {
  44             Field unsafeField = Unsafe.class.getDeclaredField("theUnsafe");
  45             unsafeField.setAccessible(true);
  46             UNSAFE = (Unsafe) unsafeField.get(null);
  47         }
  48         catch (Exception e) {
  49             throw new AssertionError(e);
  50         }
  51     }
  52 
  53     static void test1(byte[] array) {
  54         array[0] = 0;
  55         UNSAFE.putIntUnaligned(array, UNSAFE.ARRAY_BYTE_BASE_OFFSET, 0);
  56         array[0] = 0;
  57     }




  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 
  25 /**
  26  * @test
  27  * @bug 8136473
  28  * @summary Mismatched stores on same slice possible with Unsafe.Put*Unaligned methods
  29  * @modules java.base/jdk.internal.misc


  30  *
  31  * @run main/othervm -XX:-UseOnStackReplacement -XX:-BackgroundCompilation
  32  *      compiler.intrinsics.unsafe.TestUnsafeUnalignedMismatchedAccesses
  33  * @run main/othervm -XX:-UseOnStackReplacement -XX:-BackgroundCompilation
  34  *      -XX:+UnlockDiagnosticVMOptions -XX:-UseUnalignedAccesses
  35  *      compiler.intrinsics.unsafe.TestUnsafeUnalignedMismatchedAccesses
  36  */
  37 
  38 package compiler.intrinsics.unsafe;
  39 
  40 import jdk.internal.misc.Unsafe;
  41 
  42 import java.lang.reflect.Field;
  43 
  44 public class TestUnsafeUnalignedMismatchedAccesses {
  45 
  46     private static final Unsafe UNSAFE;
  47 
  48     static {
  49         try {
  50             Field unsafeField = Unsafe.class.getDeclaredField("theUnsafe");
  51             unsafeField.setAccessible(true);
  52             UNSAFE = (Unsafe) unsafeField.get(null);
  53         }
  54         catch (Exception e) {
  55             throw new AssertionError(e);
  56         }
  57     }
  58 
  59     static void test1(byte[] array) {
  60         array[0] = 0;
  61         UNSAFE.putIntUnaligned(array, UNSAFE.ARRAY_BYTE_BASE_OFFSET, 0);
  62         array[0] = 0;
  63     }


< prev index next >