commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r887896 - in /commons/sandbox/runtime/trunk/src/main: java/org/apache/commons/runtime/Memory.java native/shared/memory.c
Date Mon, 07 Dec 2009 12:01:12 GMT
Author: mturk
Date: Mon Dec  7 12:01:12 2009
New Revision: 887896

URL: http://svn.apache.org/viewvc?rev=887896&view=rev
Log:
Use native Pointer address instead calling back into JVM

Modified:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Memory.java
    commons/sandbox/runtime/trunk/src/main/native/shared/memory.c

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Memory.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Memory.java?rev=887896&r1=887895&r2=887896&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Memory.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Memory.java Mon Dec  7 12:01:12 2009
@@ -476,7 +476,7 @@
         set0(ptr.POINTER + offset, length, val);
     }
 
-    private static native byte[] array0(Pointer ptr, long offset, int length)
+    private static native byte[] array0(long ptr, int length)
         throws IndexOutOfBoundsException, OutOfMemoryError;
     /**
      * Return the {@code ptr} memory area from {@code src} to {@code byte} array.
@@ -498,13 +498,17 @@
         throws IndexOutOfBoundsException, IllegalArgumentException,
                NullPointerException, OutOfMemoryError
     {
+        if (ptr == null || ptr.POINTER == 0L)
+            throw new NullPointerException();
         if (offset < 0L || length < 1)
             throw new IllegalArgumentException();
+        if (offset + length > ptr.PLENGTH)
+            throw new IndexOutOfBoundsException();
 
-        return array0(ptr, offset, length);
+        return array0(ptr.POINTER + offset, length);
     }
 
-    private static native char[] array1(Pointer ptr, long offset, int length)
+    private static native char[] array1(long ptr, int length)
         throws IndexOutOfBoundsException, OutOfMemoryError;
     /**
      * Return the {@code ptr} memory area from {@code src} to {@code char} array.
@@ -526,13 +530,17 @@
         throws IndexOutOfBoundsException, IllegalArgumentException,
                NullPointerException, OutOfMemoryError
     {
+        if (ptr == null || ptr.POINTER == 0L)
+            throw new NullPointerException();
         if (offset < 0L || length < 1)
             throw new IllegalArgumentException();
+        if (((offset + length) * 2) > ptr.PLENGTH)
+            throw new IndexOutOfBoundsException();
 
-        return array1(ptr, offset, length);
+        return array1(ptr.POINTER + offset * 2, length);
     }
 
-    private static native short[] array2(Pointer ptr, long offset, int length)
+    private static native short[] array2(long ptr, int length)
         throws IndexOutOfBoundsException, OutOfMemoryError;
     /**
      * Return the {@code ptr} memory area from {@code src} to {@code short} array.
@@ -554,13 +562,17 @@
         throws IndexOutOfBoundsException, IllegalArgumentException,
                NullPointerException, OutOfMemoryError
     {
+        if (ptr == null || ptr.POINTER == 0L)
+            throw new NullPointerException();
         if (offset < 0L || length < 1)
             throw new IllegalArgumentException();
+        if (((offset + length) * 2) > ptr.PLENGTH)
+            throw new IndexOutOfBoundsException();
 
-        return array2(ptr, offset, length);
+        return array2(ptr.POINTER + offset * 2, length);
     }
 
-    private static native int[] array3(Pointer ptr, long offset, int length)
+    private static native int[] array3(long ptr, int length)
         throws IndexOutOfBoundsException, OutOfMemoryError;
     /**
      * Return the {@code ptr} memory area from {@code src} to {@code int} array.
@@ -582,13 +594,17 @@
         throws IndexOutOfBoundsException, IllegalArgumentException,
                NullPointerException, OutOfMemoryError
     {
+        if (ptr == null || ptr.POINTER == 0L)
+            throw new NullPointerException();
         if (offset < 0L || length < 1)
             throw new IllegalArgumentException();
+        if (((offset + length) * 4) > ptr.PLENGTH)
+            throw new IndexOutOfBoundsException();
 
-        return array3(ptr, offset, length);
+        return array3(ptr.POINTER + offset * 4, length);
     }
 
-    private static native long[] array4(Pointer ptr, long offset, int length)
+    private static native long[] array4(long ptr, int length)
         throws IndexOutOfBoundsException, OutOfMemoryError;
     /**
      * Return the {@code ptr} memory area from {@code src} to
@@ -611,13 +627,17 @@
         throws IndexOutOfBoundsException, IllegalArgumentException,
                NullPointerException, OutOfMemoryError
     {
+        if (ptr == null || ptr.POINTER == 0L)
+            throw new NullPointerException();
         if (offset < 0L || length < 1)
             throw new IllegalArgumentException();
+        if (((offset + length) * 8) > ptr.PLENGTH)
+            throw new IndexOutOfBoundsException();
 
-        return array4(ptr, offset, length);
+        return array4(ptr.POINTER + offset * 8, length);
     }
 
-    private static native float[] array5(Pointer ptr, long offset, int length)
+    private static native float[] array5(long ptr, int length)
         throws IndexOutOfBoundsException, OutOfMemoryError;
     /**
      * Return the {@code ptr} memory area from {@code src} to
@@ -640,13 +660,17 @@
         throws IndexOutOfBoundsException, IllegalArgumentException,
                NullPointerException, OutOfMemoryError
     {
+        if (ptr == null || ptr.POINTER == 0L)
+            throw new NullPointerException();
         if (offset < 0L || length < 1)
             throw new IllegalArgumentException();
+        if (((offset + length) * 4) > ptr.PLENGTH)
+            throw new IndexOutOfBoundsException();
 
-        return array5(ptr, offset, length);
+        return array5(ptr.POINTER + offset * 4, length);
     }
 
-    private static native double[] array6(Pointer ptr, long offset, int length)
+    private static native double[] array6(long ptr, int length)
         throws IndexOutOfBoundsException, OutOfMemoryError;
     /**
      * Return the {@code ptr} memory area from {@code src} to
@@ -669,15 +693,51 @@
         throws IndexOutOfBoundsException, IllegalArgumentException,
                NullPointerException, OutOfMemoryError
     {
+        if (ptr == null || ptr.POINTER == 0L)
+            throw new NullPointerException();
         if (offset < 0L || length < 1)
             throw new IllegalArgumentException();
+        if (((offset + length) * 8) > ptr.PLENGTH)
+            throw new IndexOutOfBoundsException();
 
-        return array6(ptr, offset, length);
+        return array6(ptr.POINTER + offset * 8, length);
     }
 
-    private static native void acpy0(Pointer src, long srcPos, byte[] dst,
+    private static native boolean[] array7(long ptr, int length)
+        throws IndexOutOfBoundsException, OutOfMemoryError;
+    /**
+     * Return the {@code ptr} memory area from {@code src} to {@code boolean} array.
+     *
+     * @param ptr {@code Pointer} whose content to use.
+     * @param offset starting position in the memory.
+     * @param length the number of bytes use.
+     * @return new {@code byte} array with values from {@code src} memory area.
+     *
+     * @throws IllegalArgumentException if the {@code offset}
+     *          is {@code negative} or {@code length}
+     *          is {@code zero}.
+     * @throws IndexOutOfBoundsException if the operation would cause
+     *          access of data outside allocated memory bounds.
+     * @throws NullPointerException if {@code ptr} is {@code null}.
+     * @throws OutOfMemoryError if memory cannot be dipicated.
+     */
+    public static boolean[] toBooleanArray(Pointer ptr, long offset, int length)
+        throws IndexOutOfBoundsException, IllegalArgumentException,
+               NullPointerException, OutOfMemoryError
+    {
+        if (ptr == null || ptr.POINTER == 0L)
+            throw new NullPointerException();
+        if (offset < 0L || length < 1)
+            throw new IllegalArgumentException();
+        if (offset + length > ptr.PLENGTH)
+            throw new IndexOutOfBoundsException();
+
+        return array7(ptr.POINTER + offset, length);
+    }
+
+    private static native void acpy0(long src, byte[] dst,
                                      int dstPos, int length)
-        throws IndexOutOfBoundsException;
+        throws ArrayIndexOutOfBoundsException;
     /**
      * Copy the memory area from {@code src} pointer to array
      * pointed by {@code dst}.
@@ -701,16 +761,21 @@
         throws IndexOutOfBoundsException, IllegalArgumentException,
                NullPointerException
     {
+        if (src == null || src.POINTER == 0L)
+            throw new NullPointerException();
         if (srcPos < 0L || dstPos < 0 || length == 0)
             throw new IllegalArgumentException();
-        else if ((dstPos + length) > dst.length)
+        if (dstPos + length > dst.length)
+            throw new ArrayIndexOutOfBoundsException();
+        if (srcPos + length > src.PLENGTH)
             throw new IndexOutOfBoundsException();
-        acpy0(src, srcPos, dst, dstPos, length);
+
+        acpy0(src.POINTER + srcPos, dst, dstPos, length);
     }
 
-    private static native void acpy1(Pointer src, long srcPos, char[] dst,
+    private static native void acpy1(long src, char[] dst,
                                      int dstPos, int length)
-        throws IndexOutOfBoundsException;
+        throws ArrayIndexOutOfBoundsException;
     /**
      * Copy the memory area from {@code src} pointer to array
      * pointed by {@code dst}.
@@ -734,16 +799,21 @@
         throws IndexOutOfBoundsException, IllegalArgumentException,
                NullPointerException
     {
+        if (src == null || src.POINTER == 0L)
+            throw new NullPointerException();
         if (srcPos < 0L || dstPos < 0 || length == 0)
             throw new IllegalArgumentException();
-        else if ((dstPos + length) > dst.length)
+        if (dstPos + length > dst.length)
+            throw new ArrayIndexOutOfBoundsException();
+        if (((srcPos + length) * 2) > src.PLENGTH)
             throw new IndexOutOfBoundsException();
-        acpy1(src, srcPos, dst, dstPos, length);
+
+        acpy1(src.POINTER + srcPos * 2, dst, dstPos, length);
     }
 
-    private static native void acpy2(Pointer src, long srcPos, short[] dst,
+    private static native void acpy2(long src, short[] dst,
                                      int dstPos, int length)
-        throws IndexOutOfBoundsException;
+        throws ArrayIndexOutOfBoundsException;
     /**
      * Copy the memory area from {@code src} pointer to array
      * pointed by {@code dst}.
@@ -767,16 +837,21 @@
         throws IndexOutOfBoundsException, IllegalArgumentException,
                NullPointerException
     {
+        if (src == null || src.POINTER == 0L)
+            throw new NullPointerException();
         if (srcPos < 0L || dstPos < 0 || length == 0)
             throw new IllegalArgumentException();
-        else if ((dstPos + length) > dst.length)
+        if (dstPos + length > dst.length)
+            throw new ArrayIndexOutOfBoundsException();
+        if (((srcPos + length) * 2) > src.PLENGTH)
             throw new IndexOutOfBoundsException();
-        acpy2(src, srcPos, dst, dstPos, length);
+
+        acpy2(src.POINTER + srcPos * 2, dst, dstPos, length);
     }
 
-    private static native void acpy3(Pointer src, long srcPos, int[] dst,
+    private static native void acpy3(long src, int[] dst,
                                      int dstPos, int length)
-        throws IndexOutOfBoundsException;
+        throws ArrayIndexOutOfBoundsException;
     /**
      * Copy the memory area from {@code src} pointer to array
      * pointed by {@code dst}.
@@ -800,16 +875,21 @@
         throws IndexOutOfBoundsException, IllegalArgumentException,
                NullPointerException
     {
+        if (src == null || src.POINTER == 0L)
+            throw new NullPointerException();
         if (srcPos < 0L || dstPos < 0 || length == 0)
             throw new IllegalArgumentException();
-        else if ((dstPos + length) > dst.length)
+        if (dstPos + length > dst.length)
+            throw new ArrayIndexOutOfBoundsException();
+        if (((srcPos + length) * 4) > src.PLENGTH)
             throw new IndexOutOfBoundsException();
-        acpy3(src, srcPos, dst, dstPos, length);
+
+        acpy3(src.POINTER + srcPos * 4, dst, dstPos, length);
     }
 
-    private static native void acpy4(Pointer src, long srcPos, long[] dst,
+    private static native void acpy4(long src, long[] dst,
                                      int dstPos, int length)
-        throws IndexOutOfBoundsException;
+        throws ArrayIndexOutOfBoundsException;
     /**
      * Copy the memory area from {@code src} pointer to array
      * pointed by {@code dst}.
@@ -833,16 +913,21 @@
         throws IndexOutOfBoundsException, IllegalArgumentException,
                NullPointerException
     {
+        if (src == null || src.POINTER == 0L)
+            throw new NullPointerException();
         if (srcPos < 0L || dstPos < 0 || length == 0)
             throw new IllegalArgumentException();
-        else if ((dstPos + length) > dst.length)
+        if (dstPos + length > dst.length)
+            throw new ArrayIndexOutOfBoundsException();
+        if (((srcPos + length) * 8) > src.PLENGTH)
             throw new IndexOutOfBoundsException();
-        acpy4(src, srcPos, dst, dstPos, length);
+
+        acpy4(src.POINTER + srcPos * 8, dst, dstPos, length);
     }
 
-    private static native void acpy5(Pointer src, long srcPos, float[] dst,
+    private static native void acpy5(long src, float[] dst,
                                      int dstPos, int length)
-        throws IndexOutOfBoundsException;
+        throws ArrayIndexOutOfBoundsException;
     /**
      * Copy the memory area from {@code src} pointer to array
      * pointed by {@code dst}.
@@ -866,16 +951,21 @@
         throws IndexOutOfBoundsException, IllegalArgumentException,
                NullPointerException
     {
+        if (src == null || src.POINTER == 0L)
+            throw new NullPointerException();
         if (srcPos < 0L || dstPos < 0 || length == 0)
             throw new IllegalArgumentException();
-        else if ((dstPos + length) > dst.length)
+        if (dstPos + length > dst.length)
+            throw new ArrayIndexOutOfBoundsException();
+        if (((srcPos + length) * 4) > src.PLENGTH)
             throw new IndexOutOfBoundsException();
-        acpy5(src, srcPos, dst, dstPos, length);
+
+        acpy5(src.POINTER + srcPos * 4, dst, dstPos, length);
     }
 
-    private static native void acpy6(Pointer src, long srcPos, double[] dst,
+    private static native void acpy6(long src, double[] dst,
                                      int dstPos, int length)
-        throws IndexOutOfBoundsException;
+        throws ArrayIndexOutOfBoundsException;
     /**
      * Copy the memory area from {@code src} pointer to array
      * pointed by {@code dst}.
@@ -899,16 +989,59 @@
         throws IndexOutOfBoundsException, IllegalArgumentException,
                NullPointerException
     {
+        if (src == null || src.POINTER == 0L)
+            throw new NullPointerException();
+        if (srcPos < 0L || dstPos < 0 || length == 0)
+            throw new IllegalArgumentException();
+        if (dstPos + length > dst.length)
+            throw new ArrayIndexOutOfBoundsException();
+        if (((srcPos + length) * 8) > src.PLENGTH)
+            throw new IndexOutOfBoundsException();
+
+        acpy6(src.POINTER + srcPos * 8, dst, dstPos, length);
+    }
+
+    private static native void acpy7(long src, boolean[] dst,
+                                     int dstPos, int length)
+        throws ArrayIndexOutOfBoundsException;
+    /**
+     * Copy the memory area from {@code src} pointer to array
+     * pointed by {@code dst}.
+     *
+     * @param src source memory {@code Pointer}.
+     * @param srcPos starting position in the source memory.
+     * @param dst destination {@code array}.
+     * @param dstPos starting position in the destination array.
+     * @param length the number of bytes to be copied.
+     *
+     * @throws IllegalArgumentException if the {@code srcPos} or
+     *          {@code dstPos} is {@code negative} or {@code length}
+     *          is {@code zero}.
+     * @throws IndexOutOfBoundsException if the operation would cause
+     *          access of data outside allocated memory bounds.
+     * @throws NullPointerException if {@code src} or {@code dst} is
+     *          {@code null}.
+     */
+    public static void copy(Pointer src, long srcPos, boolean[] dst,
+                            int dstPos, int length)
+        throws IndexOutOfBoundsException, IllegalArgumentException,
+               NullPointerException
+    {
+        if (src == null || src.POINTER == 0L)
+            throw new NullPointerException();
         if (srcPos < 0L || dstPos < 0 || length == 0)
             throw new IllegalArgumentException();
-        else if ((dstPos + length) > dst.length)
+        if (dstPos + length > dst.length)
+            throw new ArrayIndexOutOfBoundsException();
+        if (srcPos + length > src.PLENGTH)
             throw new IndexOutOfBoundsException();
-        acpy6(src, srcPos, dst, dstPos, length);
+
+        acpy7(src.POINTER + srcPos, dst, dstPos, length);
     }
 
-    private static native void pcpy0(byte[] src, int srcPos, Pointer dst,
-                                     long dstPos, int length)
-        throws IndexOutOfBoundsException;
+    private static native void pcpy0(byte[] src, int srcPos, long dst,
+                                     int length)
+        throws ArrayIndexOutOfBoundsException;
     /**
      * Copy the array pointed by {@code src} to the memory area
      * pointed by {@code dst} pointer.
@@ -934,18 +1067,22 @@
         throws IndexOutOfBoundsException, IllegalArgumentException,
                NullPointerException, UnsupportedOperationException
     {
+        if (dst == null || dst.POINTER == 0L)
+            throw new NullPointerException();
         if (srcPos < 0 || dstPos < 0L || length == 0)
             throw new IllegalArgumentException();
-        else if ((dstPos + length) > src.length)
+        if (dstPos + length > src.length)
+            throw new ArrayIndexOutOfBoundsException();
+        if (dstPos + length > dst.PLENGTH)
             throw new IndexOutOfBoundsException();
-        else if (dst instanceof ConstPointer)
+        if (dst.ISCONST)
             throw new UnsupportedOperationException();
-        pcpy0(src, srcPos, dst, dstPos, length);
+        pcpy0(src, srcPos, dst.POINTER + dstPos, length);
     }
 
-    private static native void pcpy1(char[] src, int srcPos, Pointer dst,
-                                     long dstPos, int length)
-        throws IndexOutOfBoundsException;
+    private static native void pcpy1(char[] src, int srcPos, long dst,
+                                     int length)
+        throws ArrayIndexOutOfBoundsException;
     /**
      * Copy the array pointed by {@code src} to the memory area
      * pointed by {@code dst} pointer.
@@ -971,18 +1108,22 @@
         throws IndexOutOfBoundsException, IllegalArgumentException,
                NullPointerException, UnsupportedOperationException
     {
+        if (dst == null || dst.POINTER == 0L)
+            throw new NullPointerException();
         if (srcPos < 0 || dstPos < 0L || length == 0)
             throw new IllegalArgumentException();
-        else if ((dstPos + length) > src.length)
+        if (dstPos + length > src.length)
+            throw new ArrayIndexOutOfBoundsException();
+        if (((dstPos + length) * 2) > dst.PLENGTH)
             throw new IndexOutOfBoundsException();
-        else if (dst instanceof ConstPointer)
+        if (dst.ISCONST)
             throw new UnsupportedOperationException();
-        pcpy1(src, srcPos, dst, dstPos, length);
+        pcpy1(src, srcPos, dst.POINTER + dstPos * 2, length);
     }
 
-    private static native void pcpy2(short[] src, int srcPos, Pointer dst,
-                                     long dstPos, int length)
-        throws IndexOutOfBoundsException;
+    private static native void pcpy2(short[] src, int srcPos, long dst,
+                                     int length)
+        throws ArrayIndexOutOfBoundsException;
     /**
      * Copy the array pointed by {@code src} to the memory area
      * pointed by {@code dst} pointer.
@@ -1008,18 +1149,22 @@
         throws IndexOutOfBoundsException, IllegalArgumentException,
                NullPointerException, UnsupportedOperationException
     {
+        if (dst == null || dst.POINTER == 0L)
+            throw new NullPointerException();
         if (srcPos < 0 || dstPos < 0L || length == 0)
             throw new IllegalArgumentException();
-        else if ((dstPos + length) > src.length)
+        if (dstPos + length > src.length)
+            throw new ArrayIndexOutOfBoundsException();
+        if (((dstPos + length) * 2) > dst.PLENGTH)
             throw new IndexOutOfBoundsException();
-        else if (dst instanceof ConstPointer)
+        if (dst.ISCONST)
             throw new UnsupportedOperationException();
-        pcpy2(src, srcPos, dst, dstPos, length);
+        pcpy2(src, srcPos, dst.POINTER + dstPos * 2, length);
     }
 
-    private static native void pcpy3(int[] src, int srcPos, Pointer dst,
-                                     long dstPos, int length)
-        throws IndexOutOfBoundsException;
+    private static native void pcpy3(int[] src, int srcPos, long dst,
+                                     int length)
+        throws ArrayIndexOutOfBoundsException;
     /**
      * Copy the array pointed by {@code src} to the memory area
      * pointed by {@code dst} pointer.
@@ -1045,18 +1190,22 @@
         throws IndexOutOfBoundsException, IllegalArgumentException,
                NullPointerException, UnsupportedOperationException
     {
+        if (dst == null || dst.POINTER == 0L)
+            throw new NullPointerException();
         if (srcPos < 0 || dstPos < 0L || length == 0)
             throw new IllegalArgumentException();
-        else if ((dstPos + length) > src.length)
+        if (dstPos + length > src.length)
+            throw new ArrayIndexOutOfBoundsException();
+        if (((dstPos + length) * 4) > dst.PLENGTH)
             throw new IndexOutOfBoundsException();
-        else if (dst instanceof ConstPointer)
+        if (dst.ISCONST)
             throw new UnsupportedOperationException();
-        pcpy3(src, srcPos, dst, dstPos, length);
+        pcpy3(src, srcPos, dst.POINTER + dstPos * 4, length);
     }
 
-    private static native void pcpy4(long[] src, int srcPos, Pointer dst,
-                                     long dstPos, int length)
-        throws IndexOutOfBoundsException;
+    private static native void pcpy4(long[] src, int srcPos, long dst,
+                                     int length)
+        throws ArrayIndexOutOfBoundsException;
     /**
      * Copy the array pointed by {@code src} to the memory area
      * pointed by {@code dst} pointer.
@@ -1082,18 +1231,22 @@
         throws IndexOutOfBoundsException, IllegalArgumentException,
                NullPointerException, UnsupportedOperationException
     {
+        if (dst == null || dst.POINTER == 0L)
+            throw new NullPointerException();
         if (srcPos < 0 || dstPos < 0L || length == 0)
             throw new IllegalArgumentException();
-        else if ((dstPos + length) > src.length)
+        if (dstPos + length > src.length)
+            throw new ArrayIndexOutOfBoundsException();
+        if (((dstPos + length) * 8) > dst.PLENGTH)
             throw new IndexOutOfBoundsException();
-        else if (dst instanceof ConstPointer)
+        if (dst.ISCONST)
             throw new UnsupportedOperationException();
-        pcpy4(src, srcPos, dst, dstPos, length);
+        pcpy4(src, srcPos, dst.POINTER + dstPos * 8, length);
     }
 
-    private static native void pcpy5(float[] src, int srcPos, Pointer dst,
-                                     long dstPos, int length)
-        throws IndexOutOfBoundsException;
+    private static native void pcpy5(float[] src, int srcPos, long dst,
+                                     int length)
+        throws ArrayIndexOutOfBoundsException;
     /**
      * Copy the array pointed by {@code src} to the memory area
      * pointed by {@code dst} pointer.
@@ -1119,18 +1272,22 @@
         throws IndexOutOfBoundsException, IllegalArgumentException,
                NullPointerException, UnsupportedOperationException
     {
+        if (dst == null || dst.POINTER == 0L)
+            throw new NullPointerException();
         if (srcPos < 0 || dstPos < 0L || length == 0)
             throw new IllegalArgumentException();
-        else if ((dstPos + length) > src.length)
+        if (dstPos + length > src.length)
+            throw new ArrayIndexOutOfBoundsException();
+        if (((dstPos + length) * 4) > dst.PLENGTH)
             throw new IndexOutOfBoundsException();
-        else if (dst instanceof ConstPointer)
+        if (dst.ISCONST)
             throw new UnsupportedOperationException();
-        pcpy5(src, srcPos, dst, dstPos, length);
+        pcpy5(src, srcPos, dst.POINTER + dstPos * 4, length);
     }
 
-    private static native void pcpy6(double[] src, int srcPos, Pointer dst,
-                                     long dstPos, int length)
-        throws IndexOutOfBoundsException;
+    private static native void pcpy6(double[] src, int srcPos, long dst,
+                                     int length)
+        throws ArrayIndexOutOfBoundsException;
     /**
      * Copy the array pointed by {@code src} to the memory area
      * pointed by {@code dst} pointer.
@@ -1156,13 +1313,58 @@
         throws IndexOutOfBoundsException, IllegalArgumentException,
                NullPointerException, UnsupportedOperationException
     {
+        if (dst == null || dst.POINTER == 0L)
+            throw new NullPointerException();
+        if (srcPos < 0 || dstPos < 0L || length == 0)
+            throw new IllegalArgumentException();
+        if (dstPos + length > src.length)
+            throw new ArrayIndexOutOfBoundsException();
+        if (((dstPos + length) * 8) > dst.PLENGTH)
+            throw new IndexOutOfBoundsException();
+        if (dst.ISCONST)
+            throw new UnsupportedOperationException();
+        pcpy6(src, srcPos, dst.POINTER + dstPos * 8, length);
+    }
+
+    private static native void pcpy7(boolean[] src, int srcPos, long dst,
+                                     int length)
+        throws ArrayIndexOutOfBoundsException;
+    /**
+     * Copy the array pointed by {@code src} to the memory area
+     * pointed by {@code dst} pointer.
+     *
+     * @param src source {@code array}.
+     * @param srcPos starting position in the source array.
+     * @param dst source memory {@code Pointer}.
+     * @param dstPos starting position in the source memory.
+     * @param length the number of bytes to be copied.
+     *
+     * @throws IllegalArgumentException if the {@code srcPos} or
+     *          {@code dstPos} is {@code negative} or {@code length}
+     *          is {@code zero}.
+     * @throws IndexOutOfBoundsException if the operation would cause
+     *          access of data outside allocated memory bounds.
+     * @throws NullPointerException if {@code src} or {@code dst} is
+     *          {@code null}.
+     * @throws UnsupportedOperationException if {@code dst} is
+     *          instance of {@code ConstPointer}.
+     */
+    public static void copy(boolean[] src, int srcPos, Pointer dst,
+                            long dstPos, int length)
+        throws IndexOutOfBoundsException, IllegalArgumentException,
+               NullPointerException, UnsupportedOperationException
+    {
+        if (dst == null || dst.POINTER == 0L)
+            throw new NullPointerException();
         if (srcPos < 0 || dstPos < 0L || length == 0)
             throw new IllegalArgumentException();
-        else if ((dstPos + length) > src.length)
+        if (dstPos + length > src.length)
+            throw new ArrayIndexOutOfBoundsException();
+        if (dstPos + length > dst.PLENGTH)
             throw new IndexOutOfBoundsException();
-        else if (dst instanceof ConstPointer)
+        if (dst.ISCONST)
             throw new UnsupportedOperationException();
-        pcpy6(src, srcPos, dst, dstPos, length);
+        pcpy7(src, srcPos, dst.POINTER + dstPos, length);
     }
 
 }

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/memory.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/memory.c?rev=887896&r1=887895&r2=887896&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/memory.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/memory.c Mon Dec  7 12:01:12 2009
@@ -568,479 +568,295 @@
     __ENDTRY
 }
 
-ACR_JNI_EXPORT_DECLARE(jbyteArray, Memory, array0)(ACR_JNISTDARGS, jobject ptr,
-                                                   jlong poff, jint size)
+ACR_JNI_EXPORT_DECLARE(jbyteArray, Memory, array0)(ACR_JNISTDARGS, jlong ptr,
+                                                   jint size)
 {
     jbyteArray ba;
-    size_t  pl;
-    size_t  dn = (size_t)poff;
-    size_t  cs = (size_t)size;
-    jbyte   *p = (jbyte *)ACR_PointerGet(_E, ptr, &pl);
+    jsize   cs = (jsize)size;
+    jbyte   *p = J2P(ptr, jbyte *);
 
-    if (!p) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ENULL, 0);
-        return NULL;
-    }
-    if ((poff + cs) > pl) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINDEX, 0);
-        return NULL;
-    }
-    ba = (*_E)->NewByteArray(_E, (jsize)cs);
+    ba = (*_E)->NewByteArray(_E, cs);
     if (ba) {
-        (*_E)->SetByteArrayRegion(_E, ba, 0, (jsize)cs, p + dn);
+        (*_E)->SetByteArrayRegion(_E, ba, 0, cs, p);
     }
     return ba;
 }
 
-ACR_JNI_EXPORT_DECLARE(jcharArray, Memory, array1)(ACR_JNISTDARGS, jobject ptr,
-                                                   jlong poff, jint size)
+ACR_JNI_EXPORT_DECLARE(jcharArray, Memory, array1)(ACR_JNISTDARGS, jlong ptr,
+                                                   jint size)
 {
     jcharArray oa;
-    size_t  pl;
-    size_t  dn = (size_t)poff;
-    size_t  cs = (size_t)size;
-    jchar   *p = (jchar *)ACR_PointerGet(_E, ptr, &pl);
+    jsize   cs = (jsize)size;
+    jchar   *p = J2P(ptr, jchar *);
 
-    if (!p) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ENULL, 0);
-        return NULL;
-    }
-    if (((poff + cs) * sizeof(jchar)) > pl) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINDEX, 0);
-        return NULL;
-    }
-    oa = (*_E)->NewCharArray(_E, (jsize)cs);
+    oa = (*_E)->NewCharArray(_E, cs);
     if (oa) {
-        (*_E)->SetCharArrayRegion(_E, oa, 0, (jsize)cs, p + dn);
+        (*_E)->SetCharArrayRegion(_E, oa, 0, cs, p);
     }
     return oa;
 }
 
-ACR_JNI_EXPORT_DECLARE(jshortArray, Memory, array2)(ACR_JNISTDARGS, jobject ptr,
-                                                    jlong poff, jint size)
+ACR_JNI_EXPORT_DECLARE(jshortArray, Memory, array2)(ACR_JNISTDARGS, jlong ptr,
+                                                    jint size)
 {
-    jshortArray oa;
-    size_t  pl;
-    size_t  dn = (size_t)poff;
-    size_t  cs = (size_t)size;
-    jshort  *p = (jshort *)ACR_PointerGet(_E, ptr, &pl);
+    jcharArray oa;
+    jsize   cs = (jsize)size;
+    jshort  *p = J2P(ptr, jshort *);
 
-    if (!p) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ENULL, 0);
-        return NULL;
-    }
-    if (((poff + cs) * sizeof(jshort)) > pl) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINDEX, 0);
-        return NULL;
-    }
-    oa = (*_E)->NewShortArray(_E, (jsize)cs);
+    oa = (*_E)->NewShortArray(_E, cs);
     if (oa) {
-        (*_E)->SetShortArrayRegion(_E, oa, 0, (jsize)cs, p + dn);
+        (*_E)->SetShortArrayRegion(_E, oa, 0, cs, p);
     }
     return oa;
 }
 
-ACR_JNI_EXPORT_DECLARE(jintArray, Memory, array3)(ACR_JNISTDARGS, jobject ptr,
-                                                  jlong poff, jint size)
+ACR_JNI_EXPORT_DECLARE(jintArray, Memory, array3)(ACR_JNISTDARGS, jlong ptr,
+                                                  jint size)
 {
     jintArray oa;
-    size_t  pl;
-    size_t  dn = (size_t)poff;
-    size_t  cs = (size_t)size;
-    jint    *p = (jint *)ACR_PointerGet(_E, ptr, &pl);
+    jsize   cs = (jsize)size;
+    jint    *p = J2P(ptr, jint *);
 
     if (!p) {
         ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ENULL, 0);
         return NULL;
     }
-    if (((poff + cs) * sizeof(jint)) > pl) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINDEX, 0);
-        return NULL;
-    }
-    oa = (*_E)->NewIntArray(_E, (jsize)cs);
+    oa = (*_E)->NewIntArray(_E, cs);
     if (oa) {
-        (*_E)->SetIntArrayRegion(_E, oa, 0, (jsize)cs, p + dn);
+        (*_E)->SetIntArrayRegion(_E, oa, 0, cs, p);
     }
     return oa;
 }
 
-ACR_JNI_EXPORT_DECLARE(jlongArray, Memory, array4)(ACR_JNISTDARGS, jobject ptr,
-                                                   jlong poff, jint size)
+ACR_JNI_EXPORT_DECLARE(jlongArray, Memory, array4)(ACR_JNISTDARGS, jlong ptr,
+                                                   jint size)
 {
     jlongArray oa;
-    size_t  pl;
-    size_t  dn = (size_t)poff;
-    size_t  cs = (size_t)size;
-    jlong   *p = (jlong *)ACR_PointerGet(_E, ptr, &pl);
+    jsize   cs = (jsize)size;
+    jlong   *p = J2P(ptr, jlong *);
 
-    if (!p) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ENULL, 0);
-        return NULL;
-    }
-    if (((poff + cs) * sizeof(jlong)) > pl) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINDEX, 0);
-        return NULL;
-    }
-    oa = (*_E)->NewLongArray(_E, (jsize)cs);
+    oa = (*_E)->NewLongArray(_E, cs);
     if (oa) {
-        (*_E)->SetLongArrayRegion(_E, oa, 0, (jsize)cs, p + dn);
+        (*_E)->SetLongArrayRegion(_E, oa, 0, cs, p);
     }
     return oa;
 }
 
-ACR_JNI_EXPORT_DECLARE(jfloatArray, Memory, array5)(ACR_JNISTDARGS, jobject ptr,
-                                                    jlong poff, jint size)
+ACR_JNI_EXPORT_DECLARE(jfloatArray, Memory, array5)(ACR_JNISTDARGS, jlong ptr,
+                                                    jint size)
 {
     jlongArray oa;
-    size_t  pl;
-    size_t  dn = (size_t)poff;
-    size_t  cs = (size_t)size;
-    jfloat  *p = (jfloat *)ACR_PointerGet(_E, ptr, &pl);
+    jsize   cs = (jsize)size;
+    jfloat  *p = J2P(ptr, jfloat *);
 
-    if (!p) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ENULL, 0);
-        return NULL;
-    }
-    if (((poff + cs) * sizeof(jfloat)) > pl) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINDEX, 0);
-        return NULL;
-    }
-    oa = (*_E)->NewFloatArray(_E, (jsize)cs);
+    oa = (*_E)->NewFloatArray(_E, cs);
     if (oa) {
-        (*_E)->SetFloatArrayRegion(_E, oa, 0, (jsize)cs, p + dn);
+        (*_E)->SetFloatArrayRegion(_E, oa, 0, cs, p);
     }
     return oa;
 }
 
-ACR_JNI_EXPORT_DECLARE(jdoubleArray, Memory, array6)(ACR_JNISTDARGS, jobject ptr,
-                                                     jlong poff, jint size)
+ACR_JNI_EXPORT_DECLARE(jdoubleArray, Memory, array6)(ACR_JNISTDARGS, jlong ptr,
+                                                     jint size)
 {
     jlongArray oa;
-    size_t  pl;
-    size_t  dn = (size_t)poff;
-    size_t  cs = (size_t)size;
-    jdouble *p = (jdouble *)ACR_PointerGet(_E, ptr, &pl);
+    jsize   cs = (jsize)size;
+    jdouble *p = J2P(ptr, jdouble *);
 
-    if (!p) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ENULL, 0);
-        return NULL;
-    }
-    if (((poff + cs) * sizeof(jdouble)) > pl) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINDEX, 0);
-        return NULL;
+    oa = (*_E)->NewDoubleArray(_E, cs);
+    if (oa) {
+        (*_E)->SetDoubleArrayRegion(_E, oa, 0, cs, p);
     }
-    oa = (*_E)->NewDoubleArray(_E, (jsize)cs);
+    return oa;
+}
+
+ACR_JNI_EXPORT_DECLARE(jdoubleArray, Memory, array7)(ACR_JNISTDARGS, jlong ptr,
+                                                     jint size)
+{
+    jlongArray oa;
+    jsize   cs = (jsize)size;
+    jboolean *p = J2P(ptr, jboolean *);
+
+    oa = (*_E)->NewBooleanArray(_E, cs);
     if (oa) {
-        (*_E)->SetDoubleArrayRegion(_E, oa, 0, (jsize)cs, p + dn);
+        (*_E)->SetBooleanArrayRegion(_E, oa, 0, cs, p);
     }
     return oa;
 }
 
 
-ACR_JNI_EXPORT_DECLARE(void, Memory, acpy0)(ACR_JNISTDARGS, jobject ptr,
-                                            jlong poff, jbyteArray dst,
+ACR_JNI_EXPORT_DECLARE(void, Memory, acpy0)(ACR_JNISTDARGS, jlong ptr,
+                                            jbyteArray dst,
                                             jint off, jint len)
 {
-    size_t  pl;
-    size_t  po = (size_t)poff;
-    size_t  cs = (size_t)len;
-    jbyte   *p = (jbyte *)ACR_PointerGet(_E, ptr, &pl);
+    jbyte   *p = J2P(ptr, jbyte *);
 
     UNREFERENCED_O;
 
-    if (!p) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ENULL, 0);
-        return;
-    }
-    if (((po + cs) * sizeof(jbyte)) > pl) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINDEX, 0);
-        return;
-    }
-    (*_E)->SetByteArrayRegion(_E, dst, (jsize)off, (jsize)len, p + po);
+    (*_E)->SetByteArrayRegion(_E, dst, (jsize)off, (jsize)len, p);
 }
 
-ACR_JNI_EXPORT_DECLARE(void, Memory, acpy1)(ACR_JNISTDARGS, jobject ptr,
-                                            jlong poff, jcharArray dst,
+ACR_JNI_EXPORT_DECLARE(void, Memory, acpy1)(ACR_JNISTDARGS, jlong ptr,
+                                            jcharArray dst,
                                             jint off, jint len)
 {
-    size_t  pl;
-    size_t  po = (size_t)poff;
-    size_t  cs = (size_t)len;
-    jchar   *p = (jchar *)ACR_PointerGet(_E, ptr, &pl);
+    jchar   *p = J2P(ptr, jchar *);
 
     UNREFERENCED_O;
 
-    if (!p) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ENULL, 0);
-        return;
-    }
-    if (((po + cs) * sizeof(jchar)) > pl) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINDEX, 0);
-        return;
-    }
-    (*_E)->SetCharArrayRegion(_E, dst, (jsize)off, (jsize)len, p + po);
+    (*_E)->SetCharArrayRegion(_E, dst, (jsize)off, (jsize)len, p);
 }
 
-ACR_JNI_EXPORT_DECLARE(void, Memory, acpy2)(ACR_JNISTDARGS, jobject ptr,
-                                            jlong poff, jshortArray dst,
+ACR_JNI_EXPORT_DECLARE(void, Memory, acpy2)(ACR_JNISTDARGS, jlong ptr,
+                                            jshortArray dst,
                                             jint off, jint len)
 {
-    size_t  pl;
-    size_t  po = (size_t)poff;
-    size_t  cs = (size_t)len;
-    jshort  *p = (jshort *)ACR_PointerGet(_E, ptr, &pl);
+    jshort  *p = J2P(ptr, jshort *);
 
     UNREFERENCED_O;
 
-    if (!p) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ENULL, 0);
-        return;
-    }
-    if (((po + cs) * sizeof(jshort)) > pl) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINDEX, 0);
-        return;
-    }
-    (*_E)->SetShortArrayRegion(_E, dst, (jsize)off, (jsize)len, p + po);
+    (*_E)->SetShortArrayRegion(_E, dst, (jsize)off, (jsize)len, p);
 }
 
-ACR_JNI_EXPORT_DECLARE(void, Memory, acpy3)(ACR_JNISTDARGS, jobject ptr,
-                                            jlong poff, jintArray dst,
+ACR_JNI_EXPORT_DECLARE(void, Memory, acpy3)(ACR_JNISTDARGS, jlong ptr,
+                                            jintArray dst,
                                             jint off, jint len)
 {
-    size_t  pl;
-    size_t  po = (size_t)poff;
-    size_t  cs = (size_t)len;
-    jint    *p = (jint *)ACR_PointerGet(_E, ptr, &pl);
+    jint    *p = J2P(ptr, jint *);
 
     UNREFERENCED_O;
 
-    if (!p) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ENULL, 0);
-        return;
-    }
-    if (((po + cs) * sizeof(jint)) > pl) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINDEX, 0);
-        return;
-    }
-    (*_E)->SetIntArrayRegion(_E, dst, (jsize)off, (jsize)len, p + po);
+    (*_E)->SetIntArrayRegion(_E, dst, (jsize)off, (jsize)len, p);
 }
 
-ACR_JNI_EXPORT_DECLARE(void, Memory, acpy4)(ACR_JNISTDARGS, jobject ptr,
-                                            jlong poff, jlongArray dst,
+ACR_JNI_EXPORT_DECLARE(void, Memory, acpy4)(ACR_JNISTDARGS, jlong ptr,
+                                            jlongArray dst,
                                             jint off, jint len)
 {
-    size_t  pl;
-    size_t  po = (size_t)poff;
-    size_t  cs = (size_t)len;
-    jlong   *p = (jlong *)ACR_PointerGet(_E, ptr, &pl);
+    jlong   *p = J2P(ptr, jlong *);
 
     UNREFERENCED_O;
 
-    if (!p) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ENULL, 0);
-        return;
-    }
-    if (((po + cs) * sizeof(jlong)) > pl) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINDEX, 0);
-        return;
-    }
-    (*_E)->SetLongArrayRegion(_E, dst, (jsize)off, (jsize)len, p + po);
+    (*_E)->SetLongArrayRegion(_E, dst, (jsize)off, (jsize)len, p);
 }
 
-ACR_JNI_EXPORT_DECLARE(void, Memory, acpy5)(ACR_JNISTDARGS, jobject ptr,
-                                            jlong poff, jfloatArray dst,
+ACR_JNI_EXPORT_DECLARE(void, Memory, acpy5)(ACR_JNISTDARGS, jlong ptr,
+                                            jfloatArray dst,
                                             jint off, jint len)
 {
-    size_t  pl;
-    size_t  po = (size_t)poff;
-    size_t  cs = (size_t)len;
-    jfloat  *p = (jfloat *)ACR_PointerGet(_E, ptr, &pl);
+    jfloat  *p = J2P(ptr, jfloat *);
 
     UNREFERENCED_O;
 
-    if (!p) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ENULL, 0);
-        return;
-    }
-    if (((po + cs) * sizeof(jfloat)) > pl) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINDEX, 0);
-        return;
-    }
-    (*_E)->SetFloatArrayRegion(_E, dst, (jsize)off, (jsize)len, p + po);
+    (*_E)->SetFloatArrayRegion(_E, dst, (jsize)off, (jsize)len, p);
 }
 
-ACR_JNI_EXPORT_DECLARE(void, Memory, acpy6)(ACR_JNISTDARGS, jobject ptr,
-                                            jlong poff, jdoubleArray dst,
+ACR_JNI_EXPORT_DECLARE(void, Memory, acpy6)(ACR_JNISTDARGS, jlong ptr,
+                                            jdoubleArray dst,
                                             jint off, jint len)
 {
-    size_t  pl;
-    size_t  po = (size_t)poff;
-    size_t  cs = (size_t)len;
-    jdouble *p = (jdouble *)ACR_PointerGet(_E, ptr, &pl);
+    jdouble *p = J2P(ptr, jdouble *);
 
     UNREFERENCED_O;
 
-    if (!p) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ENULL, 0);
-        return;
-    }
-    if (((po + cs) * sizeof(jdouble)) > pl) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINDEX, 0);
-        return;
-    }
-    (*_E)->SetDoubleArrayRegion(_E, dst, (jsize)off, (jsize)len, p + po);
+    (*_E)->SetDoubleArrayRegion(_E, dst, (jsize)off, (jsize)len, p);
+}
+
+ACR_JNI_EXPORT_DECLARE(void, Memory, acpy7)(ACR_JNISTDARGS, jlong ptr,
+                                            jbooleanArray dst,
+                                            jint off, jint len)
+{
+    jboolean *p = J2P(ptr, jboolean *);
+
+    UNREFERENCED_O;
+
+    (*_E)->SetBooleanArrayRegion(_E, dst, (jsize)off, (jsize)len, p);
 }
 
 ACR_JNI_EXPORT_DECLARE(void, Memory, pcpy0)(ACR_JNISTDARGS, jbyteArray src,
-                                            jint off,  jobject ptr,
-                                            jlong poff, jint len)
+                                            jint off,  jlong ptr,
+                                            jint len)
 {
-    size_t  pl;
-    size_t  po = (size_t)poff;
-    size_t  cs = (size_t)len;
-    jbyte   *p = (jbyte *)ACR_PointerGet(_E, ptr, &pl);
+    jbyte   *p = J2P(ptr, jbyte *);
 
     UNREFERENCED_O;
 
-    if (!p) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ENULL, 0);
-        return;
-    }
-    if (((po + cs) * sizeof(jbyte)) > pl) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINDEX, 0);
-        return;
-    }
-    (*_E)->GetByteArrayRegion(_E, src, (jsize)off, (jsize)len, p + po);
+    (*_E)->GetByteArrayRegion(_E, src, (jsize)off, (jsize)len, p);
 }
 
 ACR_JNI_EXPORT_DECLARE(void, Memory, pcpy1)(ACR_JNISTDARGS, jcharArray src,
-                                            jint off,  jobject ptr,
-                                            jlong poff, jint len)
+                                            jint off,  jlong ptr,
+                                            jint len)
 {
-    size_t  pl;
-    size_t  po = (size_t)poff;
-    size_t  cs = (size_t)len;
-    jchar   *p = (jchar *)ACR_PointerGet(_E, ptr, &pl);
+    jchar   *p = J2P(ptr, jchar *);
 
     UNREFERENCED_O;
 
-    if (!p) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ENULL, 0);
-        return;
-    }
-    if (((po + cs) * sizeof(jchar)) > pl) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINDEX, 0);
-        return;
-    }
-    (*_E)->GetCharArrayRegion(_E, src, (jsize)off, (jsize)len, p + po);
+    (*_E)->GetCharArrayRegion(_E, src, (jsize)off, (jsize)len, p);
 }
 
 ACR_JNI_EXPORT_DECLARE(void, Memory, pcpy2)(ACR_JNISTDARGS, jshortArray src,
-                                            jint off,  jobject ptr,
-                                            jlong poff, jint len)
+                                            jint off,  jlong ptr,
+                                            jint len)
 {
-    size_t  pl;
-    size_t  po = (size_t)poff;
-    size_t  cs = (size_t)len;
-    jshort  *p = (jshort *)ACR_PointerGet(_E, ptr, &pl);
+    jshort   *p = J2P(ptr, jshort *);
 
     UNREFERENCED_O;
 
-    if (!p) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ENULL, 0);
-        return;
-    }
-    if (((po + cs) * sizeof(jshort)) > pl) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINDEX, 0);
-        return;
-    }
-    (*_E)->GetShortArrayRegion(_E, src, (jsize)off, (jsize)len, p + po);
+    (*_E)->GetShortArrayRegion(_E, src, (jsize)off, (jsize)len, p);
 }
 
 ACR_JNI_EXPORT_DECLARE(void, Memory, pcpy3)(ACR_JNISTDARGS, jintArray src,
-                                            jint off,  jobject ptr,
-                                            jlong poff, jint len)
+                                            jint off,  jlong ptr,
+                                            jint len)
 {
-    size_t  pl;
-    size_t  po = (size_t)poff;
-    size_t  cs = (size_t)len;
-    jint    *p = (jint *)ACR_PointerGet(_E, ptr, &pl);
+    jint    *p = J2P(ptr, jint *);
 
     UNREFERENCED_O;
 
-    if (!p) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ENULL, 0);
-        return;
-    }
-    if (((po + cs) * sizeof(jint)) > pl) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINDEX, 0);
-        return;
-    }
-    (*_E)->GetIntArrayRegion(_E, src, (jsize)off, (jsize)len, p + po);
+    (*_E)->GetIntArrayRegion(_E, src, (jsize)off, (jsize)len, p);
 }
 
 ACR_JNI_EXPORT_DECLARE(void, Memory, pcpy4)(ACR_JNISTDARGS, jlongArray src,
-                                            jint off,  jobject ptr,
-                                            jlong poff, jint len)
+                                            jint off,  jlong ptr,
+                                            jint len)
 {
-    size_t  pl;
-    size_t  po = (size_t)poff;
-    size_t  cs = (size_t)len;
-    jlong   *p = (jlong *)ACR_PointerGet(_E, ptr, &pl);
+    jlong   *p = J2P(ptr, jlong *);
 
     UNREFERENCED_O;
 
-    if (!p) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ENULL, 0);
-        return;
-    }
-    if (((po + cs) * sizeof(jlong)) > pl) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINDEX, 0);
-        return;
-    }
-    (*_E)->GetLongArrayRegion(_E, src, (jsize)off, (jsize)len, p + po);
+    (*_E)->GetLongArrayRegion(_E, src, (jsize)off, (jsize)len, p);
 }
 
 ACR_JNI_EXPORT_DECLARE(void, Memory, pcpy5)(ACR_JNISTDARGS, jfloatArray src,
-                                            jint off,  jobject ptr,
-                                            jlong poff, jint len)
+                                            jint off,  jlong ptr,
+                                            jint len)
 {
-    size_t  pl;
-    size_t  po = (size_t)poff;
-    size_t  cs = (size_t)len;
-    jfloat  *p = (jfloat *)ACR_PointerGet(_E, ptr, &pl);
+    jfloat   *p = J2P(ptr, jfloat *);
 
     UNREFERENCED_O;
 
-    if (!p) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ENULL, 0);
-        return;
-    }
-    if (((po + cs) * sizeof(jfloat)) > pl) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINDEX, 0);
-        return;
-    }
-    (*_E)->GetFloatArrayRegion(_E, src, (jsize)off, (jsize)len, p + po);
+    (*_E)->GetFloatArrayRegion(_E, src, (jsize)off, (jsize)len, p);
 }
 
 ACR_JNI_EXPORT_DECLARE(void, Memory, pcpy6)(ACR_JNISTDARGS, jdoubleArray src,
-                                            jint off,  jobject ptr,
-                                            jlong poff, jint len)
+                                            jint off,  jlong ptr,
+                                            jint len)
 {
-    size_t  pl;
-    size_t  po = (size_t)poff;
-    size_t  cs = (size_t)len;
-    jdouble *p = (jdouble *)ACR_PointerGet(_E, ptr, &pl);
+    jdouble  *p = J2P(ptr, jdouble *);
 
     UNREFERENCED_O;
 
-    if (!p) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ENULL, 0);
-        return;
-    }
-    if (((po + cs) * sizeof(jdouble)) > pl) {
-        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINDEX, 0);
-        return;
-    }
-    (*_E)->GetDoubleArrayRegion(_E, src, (jsize)off, (jsize)len, p + po);
+    (*_E)->GetDoubleArrayRegion(_E, src, (jsize)off, (jsize)len, p);
+}
+
+ACR_JNI_EXPORT_DECLARE(void, Memory, pcpy7)(ACR_JNISTDARGS, jbooleanArray src,
+                                            jint off,  jlong ptr,
+                                            jint len)
+{
+    jboolean *p = J2P(ptr, jboolean *);
+
+    UNREFERENCED_O;
+
+    (*_E)->GetBooleanArrayRegion(_E, src, (jsize)off, (jsize)len, p);
 }



Mime
View raw message