test/jdk/internal/misc/Unsafe/CopySwap.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File jdk Sdiff test/jdk/internal/misc/Unsafe

test/jdk/internal/misc/Unsafe/CopySwap.java

Print this page
rev 15703 : [mq]: 8166045-copyswapsplit


   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 jdk.internal.misc.Unsafe;
  25 import java.lang.reflect.Field;
  26 
  27 /*
  28  * @test
  29  * @summary Test Unsafe.copySwapMemory
  30  * @modules java.base/jdk.internal.misc
  31  */
  32 public class CopySwap extends CopyCommon {
  33     private CopySwap() {
  34     }
  35 
  36     /**
  37      * Run positive tests
  38      *
  39      * @throws RuntimeException if an error is found
  40      */
  41     private void testPositive() {
  42         testSmallCopy(true);
  43         testLargeCopy(true);
  44     }
  45 
  46     /**
  47      * Run negative tests, testing corner cases and the various exceptions
  48      *
  49      * @throws RuntimeException if an error is found
  50      */
  51     private void testNegative() {
  52         long bufRaw = 0;
  53 
  54         try {
  55             bufRaw = UNSAFE.allocateMemory(1024);
  56             long buf = CopyCommon.alignUp(bufRaw, CopyCommon.BASE_ALIGNMENT);
  57             short[] arr = new short[16];
  58 
  59             // Check various illegal element sizes
  60             for (int elemSize = 2; elemSize <= 8; elemSize <<= 1) {
  61                 long[] illegalSizes = { -1, 1, elemSize - 1, elemSize + 1, elemSize * 2 - 1 };
  62                 for (long size : illegalSizes) {
  63                     try {




   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 jdk.internal.misc.Unsafe;

  25 
  26 /*
  27  * @test
  28  * @summary Test Unsafe.copySwapMemory
  29  * @modules java.base/jdk.internal.misc
  30  */
  31 public class CopySwap extends CopyCommon {
  32     private CopySwap() {
  33     }
  34 
  35     /**
  36      * Run positive tests
  37      *
  38      * @throws RuntimeException if an error is found
  39      */
  40     private void testPositive() {
  41         testSmallCopy(true);

  42     }
  43 
  44     /**
  45      * Run negative tests, testing corner cases and the various exceptions
  46      *
  47      * @throws RuntimeException if an error is found
  48      */
  49     private void testNegative() {
  50         long bufRaw = 0;
  51 
  52         try {
  53             bufRaw = UNSAFE.allocateMemory(1024);
  54             long buf = CopyCommon.alignUp(bufRaw, CopyCommon.BASE_ALIGNMENT);
  55             short[] arr = new short[16];
  56 
  57             // Check various illegal element sizes
  58             for (int elemSize = 2; elemSize <= 8; elemSize <<= 1) {
  59                 long[] illegalSizes = { -1, 1, elemSize - 1, elemSize + 1, elemSize * 2 - 1 };
  60                 for (long size : illegalSizes) {
  61                     try {


test/jdk/internal/misc/Unsafe/CopySwap.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File