Author: mturk
Date: Wed Aug 17 06:58:53 2011
New Revision: 1158543

URL: http://svn.apache.org/viewvc?rev=1158543&view=rev
Log:
Axe extra off param to functions expecting native address represented as long

Modified:
    
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Reader.java
    
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Stream.java
    
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Writer.java
    
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/IpcStream.java
    
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SocketStream.java
    
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Deflater.java
    
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Inflater.java
    
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Utils.java
    
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/bzip2/Bzip2.java
    commons/sandbox/runtime/trunk/src/main/native/os/unix/sockstream.c
    commons/sandbox/runtime/trunk/src/main/native/os/win32/ipcsstream.c
    commons/sandbox/runtime/trunk/src/main/native/os/win32/sockstream.c
    
commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestUtils.java

Modified: 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Reader.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Reader.java?rev=1158543&r1=1158542&r2=1158543&view=diff
==============================================================================
--- 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Reader.java
 (original)
+++ 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Reader.java
 Wed Aug 17 06:58:53 2011
@@ -185,6 +185,38 @@ public interface Reader
         throws NullPointerException, IndexOutOfBoundsException, IOException;
 
     /**
+     * Reads at most {@code count} bytes from the current position in
+     * this stream and stores them in the memory pointed by {@code address}.
+     * Blocks until {@code count} bytes have
+     * been read, the end of the stream is reached or an exception is thrown.
+     *
+     * @param address
+     *          The native address in which to store the bytes read from
+     *          this reader.
+     * @param count
+     *          The maximum number of bytes to store in {@code address}.
+     *
+     * @return The number of bytes actually read or {@code -1} if the end of
+     *         the stream has been reached.
+     *
+     * @throws NullPointerException
+     *          If {@code pointer} is {@code null}.
+     * @throws IndexOutOfBoundsException
+     *          If {@code offset < 0}.
+     * @throws ClosedDescriptorException
+     *          If this file is closed.
+     * @throws OperationWouldBlockException
+     *          If the stream is in nonblocking mode and the operation
+     *          would block.
+     * @throws TimeoutException
+     *          If read operation times out.
+     * @throws IOException
+     *          If some other I/O error occurs.
+     */
+    public int read(long address, int count)
+        throws NullPointerException, IndexOutOfBoundsException, IOException;
+        
+    /**
      * Reads bytes from the current position in this stream and stores them
      * in the {@code ByteBuffer} {@code buffer}. The maximum number of bytes
      * read corresponds to the size of {@code buffer}.

Modified: 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Stream.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Stream.java?rev=1158543&r1=1158542&r2=1158543&view=diff
==============================================================================
--- 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Stream.java
 (original)
+++ 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Stream.java
 Wed Aug 17 06:58:53 2011
@@ -22,6 +22,7 @@ import java.io.IOException;
 import java.io.SyncFailedException;
 import java.nio.ByteBuffer;
 import org.apache.commons.runtime.Pointer;
+import org.apache.commons.runtime.util.Utils;
 
 /**
  * Bidirectional Stream.
@@ -184,7 +185,18 @@ public abstract class Stream
     {
         if (!canRead())
             throw new OperationNotSupportedException();
-        return read(pointer, 0L, (int)pointer.sizeof());
+        return read(pointer.address(), Utils.toInteger(pointer.sizeof()));
+    }
+
+    @Override
+    public final int read(Pointer pointer, long off, int count)
+        throws IOException
+    {
+        if (!canRead())
+            throw new OperationNotSupportedException();
+        if (off + count > pointer.sizeof())
+            throw new IndexOutOfBoundsException();
+        return read(pointer.address() + off, count);
     }
 
     @Override
@@ -211,7 +223,18 @@ public abstract class Stream
     {
         if (!canWrite())
             throw new OperationNotSupportedException();
-        return write(pointer, 0L, (int)pointer.sizeof());
+        return write(pointer.address(), Utils.toInteger(pointer.sizeof()));
+    }
+
+    @Override
+    public final int write(Pointer pointer, long off, int count)
+        throws IOException
+    {
+        if (!canWrite())
+            throw new OperationNotSupportedException();
+        if (off + count > pointer.sizeof())
+            throw new IndexOutOfBoundsException();
+        return write(pointer.address() + off, count);
     }
 
     @Override

Modified: 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Writer.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Writer.java?rev=1158543&r1=1158542&r2=1158543&view=diff
==============================================================================
--- 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Writer.java
 (original)
+++ 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Writer.java
 Wed Aug 17 06:58:53 2011
@@ -163,6 +163,33 @@ public interface Writer extends Syncable
         throws IndexOutOfBoundsException, IOException;
 
     /**
+     * Writes {@code count} bytes from the {@code address}
+     * to this stream, starting at the current stream position.
+     *
+     * @param address
+     *          Native pointer to write to this stream.
+     * @param count
+     *            The number of bytes from {@code address} to write.
+     * @return The number of bytes actually written.
+     *
+     * @throws NullPointerException
+     *          If {@code pointer} is {@code null}.
+     * @throws IndexOutOfBoundsException
+     *          If {@code count < 0}.
+     * @throws ClosedDescriptorException
+     *          If this stream is closed.
+     * @throws OperationWouldBlockException
+     *          If the stream is in nonblocking mode and the operation
+     *          would block.
+     * @throws TimeoutException
+     *          If write operation times out.
+     * @throws IOException
+     *          If some other I/O error occurs.
+     */
+    public int write(long address, int count)
+        throws IndexOutOfBoundsException, IOException;
+        
+    /**
      * Writes the entire contents of the {@code ByteBuffer} {@code buffer}
      * to this stream, starting at the current stream position.
      * <p>

Modified: 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/IpcStream.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/IpcStream.java?rev=1158543&r1=1158542&r2=1158543&view=diff
==============================================================================
--- 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/IpcStream.java
 (original)
+++ 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/IpcStream.java
 Wed Aug 17 06:58:53 2011
@@ -56,7 +56,7 @@ class IpcStream extends Stream
         throws IOException;
     private static native int           read1(long nd, byte[] buf, int off, 
int len)
         throws IOException;
-    private static native int           read2(long nd, long ptr, long off, int 
len)
+    private static native int           read2(long nd, long ptr, int len)
         throws IOException;
     private static native int           read3(long nd, ByteBuffer buf, int 
off, int len)
         throws IOException;
@@ -65,7 +65,7 @@ class IpcStream extends Stream
         throws IOException;
     private static native int           write1(long nd, byte[] buf, int off, 
int len)
         throws IOException;
-    private static native int           write2(long nd, long ptr, long off, 
int len)
+    private static native int           write2(long nd, long ptr, int len)
         throws IOException;
     private static native int           write3(long nd, ByteBuffer buf, int 
off, int len)
         throws IOException;
@@ -214,12 +214,12 @@ class IpcStream extends Stream
     }
 
     @Override
-    public int read(Pointer pointer, long offset, int count)
+    public int read(long address, int count)
         throws NullPointerException, IndexOutOfBoundsException, IOException
     {
         if (closed())
             throw new ClosedDescriptorException();
-        return read2(nd, pointer.address(), offset, count);
+        return read2(nd, address, count);
     }
 
     @Override
@@ -252,12 +252,12 @@ class IpcStream extends Stream
     }
 
     @Override
-    public int write(Pointer pointer, long offset, int count)
+    public int write(long address, int count)
         throws IndexOutOfBoundsException, IOException
     {
         if (closed())
             throw new ClosedDescriptorException();
-        return write2(nd, pointer.address(), offset, count);
+        return write2(nd, address, count);
     }
 
     @Override

Modified: 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SocketStream.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SocketStream.java?rev=1158543&r1=1158542&r2=1158543&view=diff
==============================================================================
--- 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SocketStream.java
 (original)
+++ 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SocketStream.java
 Wed Aug 17 06:58:53 2011
@@ -56,7 +56,7 @@ class SocketStream extends Stream
         throws IOException;
     private static native int           read1(long nd, byte[] buf, int off, 
int len)
         throws IOException;
-    private static native int           read2(long nd, long ptr, long off, int 
len)
+    private static native int           read2(long nd, long ptr, int len)
         throws IOException;
     private static native int           read3(long nd, ByteBuffer buf, int 
off, int len)
         throws IOException;
@@ -65,7 +65,7 @@ class SocketStream extends Stream
         throws IOException;
     private static native int           write1(long nd, byte[] buf, int off, 
int len)
         throws IOException;
-    private static native int           write2(long nd, long ptr, long off, 
int len)
+    private static native int           write2(long nd, long ptr, int len)
         throws IOException;
     private static native int           write3(long nd, ByteBuffer buf, int 
off, int len)
         throws IOException;
@@ -214,12 +214,12 @@ class SocketStream extends Stream
     }
 
     @Override
-    public int read(Pointer pointer, long offset, int count)
+    public int read(long address, int count)
         throws NullPointerException, IndexOutOfBoundsException, IOException
     {
         if (closed())
             throw new ClosedDescriptorException();
-        return read2(nd, pointer.address(), offset, count);
+        return read2(nd, address, count);
     }
 
     @Override
@@ -252,12 +252,12 @@ class SocketStream extends Stream
     }
 
     @Override
-    public int write(Pointer pointer, long offset, int count)
+    public int write(long address, int count)
         throws IndexOutOfBoundsException, IOException
     {
         if (closed())
             throw new ClosedDescriptorException();
-        return write2(nd, pointer.address(), offset, count);
+        return write2(nd, address, count);
     }
     
     @Override

Modified: 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Deflater.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Deflater.java?rev=1158543&r1=1158542&r2=1158543&view=diff
==============================================================================
--- 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Deflater.java
 (original)
+++ 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Deflater.java
 Wed Aug 17 06:58:53 2011
@@ -190,7 +190,7 @@ public abstract class Deflater implement
     public void setInput(Pointer b)
         throws InvalidArgumentException
     {
-        int len = Utils.unsignedInteger(b.sizeof());
+        int len = Utils.toInteger(b.sizeof());
         if (len < 1)
             throw new InvalidArgumentException();
         setInput(b, 0L, len);
@@ -325,7 +325,7 @@ public abstract class Deflater implement
     {
         if (b == null)
             throw new NullPointerException();
-        int len = Utils.unsignedInteger(b.sizeof());
+        int len = Utils.toInteger(b.sizeof());
         if (len < 1)
             throw new InvalidArgumentException();
         return deflate(b, 0, len);

Modified: 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Inflater.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Inflater.java?rev=1158543&r1=1158542&r2=1158543&view=diff
==============================================================================
--- 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Inflater.java
 (original)
+++ 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Inflater.java
 Wed Aug 17 06:58:53 2011
@@ -163,7 +163,7 @@ public abstract class Inflater implement
     public void setInput(Pointer b)
         throws InvalidArgumentException
     {
-        int len = Utils.unsignedInteger(b.sizeof());
+        int len = Utils.toInteger(b.sizeof());
         if (len < 1)
             throw new InvalidArgumentException();
         setInput(b, 0L, len);
@@ -313,7 +313,7 @@ public abstract class Inflater implement
                InvalidDataException,
                OutOfMemoryError
     {
-        int len = Utils.unsignedInteger(b.sizeof());
+        int len = Utils.toInteger(b.sizeof());
         if (len < 1)
             throw new InvalidArgumentException();
         return inflate(b, 0L, len);

Modified: 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Utils.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Utils.java?rev=1158543&r1=1158542&r2=1158543&view=diff
==============================================================================
--- 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Utils.java
 (original)
+++ 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Utils.java
 Wed Aug 17 06:58:53 2011
@@ -404,17 +404,21 @@ public final class Utils
     /**
      * Safely cast long to integer.
      * <p>
-     * If the {@code val} is larger then {@code Integer.MAX_VALUE} returned
-     * value is {@code Integer.MAX_VALUE}.
+     * This method ensures that long value doesn't flip to negative values when
+     * casting long to integer. If the {@code val} is larger then
+     * {@code Integer.MAX_VALUE} returned value is simply
+     * {@code Integer.MAX_VALUE}.
      *</p>
      *
      * @param val value to cast.
-     * @return integer in range {@code 0 to Integer.MAX_VALUE}.
+     * @return integer in range {@code Integer.MIN_VALUE to Integer.MAX_VALUE}.
      */
-    public static int unsignedInteger(long val)
+    public static int toInteger(long val)
     {
-        if (val < 0L)
+        if (val == 0L)
             return 0;
+        else if (val < Integer.MIN_VALUE)
+            return Integer.MIN_VALUE;
         else if (val > Integer.MAX_VALUE)
             return Integer.MAX_VALUE;
         else

Modified: 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/bzip2/Bzip2.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/bzip2/Bzip2.java?rev=1158543&r1=1158542&r2=1158543&view=diff
==============================================================================
--- 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/bzip2/Bzip2.java
 (original)
+++ 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/bzip2/Bzip2.java
 Wed Aug 17 06:58:53 2011
@@ -266,7 +266,7 @@ public final class Bzip2
             throw new InvalidArgumentException();
         long srca = src.address() + srcPos;
         long dsta = dst.address() + dstPos;
-        int  dlen = Utils.unsignedInteger(dst.sizeof()  - dstPos);
+        int  dlen = Utils.toInteger(dst.sizeof()  - dstPos);
         if (dlen < 1 || srcPos < 0L || dstPos < 0L)
             throw new IndexOutOfBoundsException();
         return deflate2(srca, dsta, (int)dlen, length, blockSize100k, 
workFactor);
@@ -391,7 +391,7 @@ public final class Bzip2
     {
         long srca = src.address() + srcPos;
         long dsta = dst.address() + dstPos;
-        int  dlen = Utils.unsignedInteger(dst.sizeof()  - dstPos);
+        int  dlen = Utils.toInteger(dst.sizeof()  - dstPos);
         if (dlen < 1 || srcPos < 0L || dstPos < 0L)
             throw new IndexOutOfBoundsException();
         /* TODO: Check for param validity */

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/sockstream.c
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/sockstream.c?rev=1158543&r1=1158542&r2=1158543&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/sockstream.c 
(original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/sockstream.c Wed Aug 
17 06:58:53 2011
@@ -264,14 +264,11 @@ finally:
 }
 
 ACR_NET_EXPORT(jint, SocketStream, read2)(JNI_STDARGS, jlong sp,
-                                          jlong pa,
-                                          jlong off,
-                                          jint len)
+                                          jlong pa, jint len)
 {
     int sd;
     int rc = 0;
     ssize_t   rd = 0;
-    ptrdiff_t po = (ptrdiff_t)off;
     char     *bb = J2P(pa, char *);
     acr_ss_t *ss = J2P(sp, acr_ss_t *);
 
@@ -289,13 +286,13 @@ ACR_NET_EXPORT(jint, SocketStream, read2
         ACR_CLRFLAG(ss->fd, ACR_SO_RPART);
         goto waitio;
     }
-    rd = r_read(sd, bb + po, len);
+    rd = r_read(sd, bb, len);
     if (rd == -1 && ACR_STATUS_IS_EAGAIN(errno) && ss->fd->timeout > 0) {
 waitio:
         rc = AcrWaitIO(sd, ss->fd->timeout, POLLIN);
         if (rc != 0)
             goto finally;
-        rd = r_read(sd, bb + po, len);
+        rd = r_read(sd, bb, len);
     }
     if (rd == -1)
         rc = ACR_GET_NETOS_ERROR();
@@ -451,13 +448,10 @@ finally:
 }
 
 ACR_NET_EXPORT(jint, SocketStream, write2)(JNI_STDARGS, jlong sp,
-                                           jlong pa,
-                                           jlong off,
-                                           jint len)
+                                           jlong pa, jint len)
 {
     int sd;
     int rc = 0;
-    ptrdiff_t po = (ptrdiff_t)off;
     ssize_t wr   = 0;
     char     *bb = J2P(pa, char *);
     acr_ss_t *ss = J2P(sp, acr_ss_t *);
@@ -474,13 +468,13 @@ ACR_NET_EXPORT(jint, SocketStream, write
         ACR_CLRFLAG(ss->fd, ACR_SO_WPART);
         goto waitio;
     }
-    wr = r_write(sd, bb + po, len);
+    wr = r_write(sd, bb, len);
     if (wr == -1 && ACR_STATUS_IS_EAGAIN(errno) && ss->fd->timeout > 0) {
 waitio:
         rc = AcrWaitIO(sd, ss->fd->timeout, POLLOUT);
         if (rc != 0)
             goto finally;
-        wr = r_write(sd, bb + po, len);
+        wr = r_write(sd, bb, len);
     }
     if (wr == -1)
         rc = ACR_GET_NETOS_ERROR();

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/ipcsstream.c
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/ipcsstream.c?rev=1158543&r1=1158542&r2=1158543&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/ipcsstream.c 
(original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/ipcsstream.c Wed Aug 
17 06:58:53 2011
@@ -204,14 +204,11 @@ finally:
 }
 
 ACR_NET_EXPORT(jint, IpcStream, read2)(JNI_STDARGS, jlong sp,
-                                       jlong pa,
-                                       jlong off,
-                                       jint len)
+                                       jlong pa, jint len)
 {
     int rc = 0;
     int rd = 0;
     LPIPCSOCK cp;
-    ptrdiff_t po = (ptrdiff_t)off;
     char     *bb = J2P(pa, char *);
     acr_ss_t *ss = J2P(sp, acr_ss_t *);
 
@@ -226,9 +223,9 @@ ACR_NET_EXPORT(jint, IpcStream, read2)(J
         goto finally;
     }
     if (cp->dwPageSize == 0)
-        rd = AcrIpcRecv(cp, bb + po, len);
+        rd = AcrIpcRecv(cp, bb, len);
     else
-        rd = AcrIpcRead(cp, bb + po, len);
+        rd = AcrIpcRead(cp, bb, len);
     if (rd == -1) {
         rc = GetLastError();
         goto finally;
@@ -356,13 +353,10 @@ finally:
 }
 
 ACR_NET_EXPORT(jint, IpcStream, write2)(JNI_STDARGS, jlong sp,
-                                        jlong pa,
-                                        jlong off,
-                                        jint len)
+                                        jlong pa, jint len)
 {
     int rc = 0;
     int wr = 0;
-    ptrdiff_t po = (ptrdiff_t)off;
     LPIPCSOCK cp;
     char     *bb = J2P(pa, char *);
     acr_ss_t *ss = J2P(sp, acr_ss_t *);
@@ -376,9 +370,9 @@ ACR_NET_EXPORT(jint, IpcStream, write2)(
         goto finally;
     }
     if (cp->dwPageSize == 0)
-        wr = AcrIpcSend(cp,  bb + po, len, ss->sd->flags);
+        wr = AcrIpcSend(cp,  bb, len, ss->sd->flags);
     else
-        wr = AcrIpcWrite(cp, bb + po, len, ss->sd->flags);
+        wr = AcrIpcWrite(cp, bb, len, ss->sd->flags);
     if (wr == -1)
         rc = GetLastError();
 finally:

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/sockstream.c
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/sockstream.c?rev=1158543&r1=1158542&r2=1158543&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/sockstream.c 
(original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/sockstream.c Wed Aug 
17 06:58:53 2011
@@ -260,14 +260,11 @@ finally:
 }
 
 ACR_NET_EXPORT(jint, SocketStream, read2)(JNI_STDARGS, jlong sp,
-                                          jlong pa,
-                                          jlong off,
-                                          jint len)
+                                          jlong pa, jint len)
 {
     int rc = 0;
     int rd = 0;
     SOCKET    sd;
-    ptrdiff_t po = (ptrdiff_t)off;
     char     *bb = J2P(pa, char *);
     acr_ss_t *ss = J2P(sp, acr_ss_t *);
 
@@ -285,14 +282,14 @@ ACR_NET_EXPORT(jint, SocketStream, read2
         ACR_CLRFLAG(ss->fd, ACR_SO_RPART);
         goto waitio;
     }
-    rd = recv(sd, bb + po, len, 0);
+    rd = recv(sd, bb, len, 0);
     if (rd == SOCKET_ERROR && (WSAGetLastError() == WSAEWOULDBLOCK) &&
         ss->fd->timeout > 0) {
 waitio:
         rc = AcrWaitIO(sd, ss->fd->timeout, POLLIN);
         if (rc != 0)
             goto finally;
-        rd = recv(sd, bb + po, len, 0);
+        rd = recv(sd, bb, len, 0);
     }
     if (rd == SOCKET_ERROR)
         rc = ACR_GET_NETOS_ERROR();
@@ -451,13 +448,10 @@ finally:
 }
 
 ACR_NET_EXPORT(jint, SocketStream, write2)(JNI_STDARGS, jlong sp,
-                                           jlong pa,
-                                           jlong off,
-                                           jint len)
+                                           jlong pa, jint len)
 {
     int rc = 0;
     int wr = 0;
-    ptrdiff_t po = (ptrdiff_t)off;
     SOCKET    sd;
     char     *bb = J2P(pa, char *);
     acr_ss_t *ss = J2P(sp, acr_ss_t *);
@@ -474,14 +468,14 @@ ACR_NET_EXPORT(jint, SocketStream, write
         ACR_CLRFLAG(ss->fd, ACR_SO_WPART);
         goto waitio;
     }
-    wr = send(sd, bb + po, len, 0);
+    wr = send(sd, bb, len, 0);
     if (wr == SOCKET_ERROR && (WSAGetLastError() == WSAEWOULDBLOCK) &&
         ss->fd->timeout > 0) {
 waitio:
         rc = AcrWaitIO(sd, ss->fd->timeout, POLLOUT);
         if (rc != 0)
             goto finally;
-        wr = send(sd, bb + po, len, 0);
+        wr = send(sd, bb, len, 0);
     }
     if (wr == SOCKET_ERROR)
         rc = ACR_GET_NETOS_ERROR();

Modified: 
commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestUtils.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestUtils.java?rev=1158543&r1=1158542&r2=1158543&view=diff
==============================================================================
--- 
commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestUtils.java
 (original)
+++ 
commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestUtils.java
 Wed Aug 17 06:58:53 2011
@@ -91,6 +91,17 @@ public class TestUtils extends Assert
         assertEquals(s[1], "bcd");
     }
 
+    @Test(groups = { "core" })
+    public void toInteger()
+        throws Exception
+    {
+        long pi = Integer.MAX_VALUE + 7L;
+        long ni = Integer.MIN_VALUE - 3L;
+        assertEquals(Utils.toInteger(pi), Integer.MAX_VALUE);
+        assertEquals(Utils.toInteger(ni), Integer.MIN_VALUE);
+
+    }
+
     @Test(groups = { "core" }, expectedExceptions = TimeoutException.class)
     public void checkTimeoutException()
         throws Exception


Reply via email to