test/jdk/internal/misc/Unsafe/CopyMemory.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/CopyMemory.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.copyMemory
  30  * @modules java.base/jdk.internal.misc
  31  */
  32 public class CopyMemory extends CopyCommon {
  33     private CopyMemory() {
  34     }
  35 
  36     /**
  37      * Run positive tests
  38      *
  39      * @throws RuntimeException if an error is found
  40      */
  41     private void testPositive() {
  42         testSmallCopy(false);
  43         testLargeCopy(false);
  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 illegal sizes
  60             System.out.println("Testing negative size");
  61             try {
  62                 UNSAFE.copyMemory(null, buf, null, buf, -1);
  63                 throw new RuntimeException("copyMemory failed to throw IAE for size=-1");




   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.copyMemory
  29  * @modules java.base/jdk.internal.misc
  30  */
  31 public class CopyMemory extends CopyCommon {
  32     private CopyMemory() {
  33     }
  34 
  35     /**
  36      * Run positive tests
  37      *
  38      * @throws RuntimeException if an error is found
  39      */
  40     private void testPositive() {
  41         testSmallCopy(false);

  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 illegal sizes
  58             System.out.println("Testing negative size");
  59             try {
  60                 UNSAFE.copyMemory(null, buf, null, buf, -1);
  61                 throw new RuntimeException("copyMemory failed to throw IAE for size=-1");


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