harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r884518 [6/8] - in /harmony/enhanced/classlib/branches/java6: ./ depends/build/ depends/jars/ make/ modules/accessibility/make/ modules/accessibility/src/main/java/javax/accessibility/ modules/applet/src/main/java/org/apache/harmony/applet/...
Date Thu, 26 Nov 2009 11:12:56 GMT
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/platform/OSFileSystem.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/platform/OSFileSystem.java?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/platform/OSFileSystem.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/platform/OSFileSystem.java Thu Nov 26 11:12:49 2009
@@ -35,124 +35,124 @@
     }
 
     private OSFileSystem() {
-		super();
-	}
+        super();
+    }
+
+    private final void validateLockArgs(int type, long start, long length) {
+        if ((type != IFileSystem.SHARED_LOCK_TYPE)
+                && (type != IFileSystem.EXCLUSIVE_LOCK_TYPE)) {
+            throw new IllegalArgumentException("Illegal lock type requested."); //$NON-NLS-1$
+        }
+
+        // Start position
+        if (start < 0) {
+            throw new IllegalArgumentException(
+                    "Lock start position must be non-negative"); //$NON-NLS-1$
+        }
+
+        // Length of lock stretch
+        if (length < 0) {
+            throw new IllegalArgumentException(
+                    "Lock length must be non-negative"); //$NON-NLS-1$
+        }
+    }
+
+    private native int lockImpl(long fileDescriptor, long start, long length,
+            int type, boolean wait);
+
+    /**
+     * Returns the granularity for virtual memory allocation.
+     * Note that this value for Windows differs from the one for the
+     * page size (64K and 4K respectively).
+     */
+    public native int getAllocGranularity() throws IOException;
+
+    public boolean lock(long fileDescriptor, long start, long length, int type,
+            boolean waitFlag) throws IOException {
+        // Validate arguments
+        validateLockArgs(type, start, length);
+        int result = lockImpl(fileDescriptor, start, length, type, waitFlag);
+        return result != -1;
+    }
+
+    private native int unlockImpl(long fileDescriptor, long start, long length);
+
+    public void unlock(long fileDescriptor, long start, long length)
+            throws IOException {
+        // Validate arguments
+        validateLockArgs(IFileSystem.SHARED_LOCK_TYPE, start, length);
+        int result = unlockImpl(fileDescriptor, start, length);
+        if (result == -1) {
+            throw new IOException();
+        }
+    }
+
+    private native int fflushImpl(long fd, boolean metadata);
+
+    public void fflush(long fileDescriptor, boolean metadata)
+            throws IOException {
+        int result = fflushImpl(fileDescriptor, metadata);
+        if (result == -1) {
+            throw new IOException();
+        }
+    }
 
-	private final void validateLockArgs(int type, long start, long length) {
-		if ((type != IFileSystem.SHARED_LOCK_TYPE)
-				&& (type != IFileSystem.EXCLUSIVE_LOCK_TYPE)) {
-			throw new IllegalArgumentException("Illegal lock type requested."); //$NON-NLS-1$
-		}
-
-		// Start position
-		if (start < 0) {
-			throw new IllegalArgumentException(
-					"Lock start position must be non-negative"); //$NON-NLS-1$
-		}
-
-		// Length of lock stretch
-		if (length < 0) {
-			throw new IllegalArgumentException(
-					"Lock length must be non-negative"); //$NON-NLS-1$
-		}
-	}
-
-	private native int lockImpl(long fileDescriptor, long start, long length,
-			int type, boolean wait);
-
-	/**
-	 * Returns the granularity for virtual memory allocation.
-	 * Note that this value for Windows differs from the one for the
-	 * page size (64K and 4K respectively).
-	 */
-	public native int getAllocGranularity() throws IOException;
-
-	public boolean lock(long fileDescriptor, long start, long length, int type,
-			boolean waitFlag) throws IOException {
-		// Validate arguments
-		validateLockArgs(type, start, length);
-		int result = lockImpl(fileDescriptor, start, length, type, waitFlag);
-		return result != -1;
-	}
-
-	private native int unlockImpl(long fileDescriptor, long start, long length);
-
-	public void unlock(long fileDescriptor, long start, long length)
-			throws IOException {
-		// Validate arguments
-		validateLockArgs(IFileSystem.SHARED_LOCK_TYPE, start, length);
-		int result = unlockImpl(fileDescriptor, start, length);
-		if (result == -1) {
-			throw new IOException();
-		}
-	}
-
-	private native int fflushImpl(long fd, boolean metadata);
-
-	public void fflush(long fileDescriptor, boolean metadata)
-			throws IOException {
-		int result = fflushImpl(fileDescriptor, metadata);
-		if (result == -1) {
-			throw new IOException();
-		}
-	}
-
-	/*
-	 * File position seeking.
-	 */
-
-	private native long seekImpl(long fd, long offset, int whence);
-
-	public long seek(long fileDescriptor, long offset, int whence)
-			throws IOException {
-		long pos = seekImpl(fileDescriptor, offset, whence);
-		if (pos == -1) {
-			throw new IOException();
-		}
-		return pos;
-	}
-
-	/*
-	 * Direct read/write APIs work on addresses.
-	 */
-	private native long readDirectImpl(long fileDescriptor, long address,
-			int offset, int length);
-
-	public long readDirect(long fileDescriptor, long address, int offset,
-			int length) throws IOException {
-		long bytesRead = readDirectImpl(fileDescriptor, address, offset, length);
-		if (bytesRead < -1) {
-			throw new IOException();
-		}
-		return bytesRead;
-	}
-
-	private native long writeDirectImpl(long fileDescriptor, long address,
-			int offset, int length);
-
-	public long writeDirect(long fileDescriptor, long address, int offset,
-			int length) throws IOException {
-		long bytesWritten = writeDirectImpl(fileDescriptor, address, offset,
-				length);
-		if (bytesWritten < 0) {
-			throw new IOException();
-		}
-		return bytesWritten;
-	}
-
-	/*
-	 * Indirect read/writes work on byte[]'s
-	 */
-	private native long readImpl(long fileDescriptor, byte[] bytes, int offset,
-			int length);
-
-	public long read(long fileDescriptor, byte[] bytes, int offset, int length)
-			throws IOException {
-		if (bytes == null) {
-			throw new NullPointerException();
-		}
-		long bytesRead = readImpl(fileDescriptor, bytes, offset, length);
-		if (bytesRead < -1) {
+    /*
+     * File position seeking.
+     */
+
+    private native long seekImpl(long fd, long offset, int whence);
+
+    public long seek(long fileDescriptor, long offset, int whence)
+            throws IOException {
+        long pos = seekImpl(fileDescriptor, offset, whence);
+        if (pos == -1) {
+            throw new IOException();
+        }
+        return pos;
+    }
+
+    /*
+     * Direct read/write APIs work on addresses.
+     */
+    private native long readDirectImpl(long fileDescriptor, long address,
+            int offset, int length);
+
+    public long readDirect(long fileDescriptor, long address, int offset,
+            int length) throws IOException {
+        long bytesRead = readDirectImpl(fileDescriptor, address, offset, length);
+        if (bytesRead < -1) {
+            throw new IOException();
+        }
+        return bytesRead;
+    }
+
+    private native long writeDirectImpl(long fileDescriptor, long address,
+            int offset, int length);
+
+    public long writeDirect(long fileDescriptor, long address, int offset,
+            int length) throws IOException {
+        long bytesWritten = writeDirectImpl(fileDescriptor, address, offset,
+                length);
+        if (bytesWritten < 0) {
+            throw new IOException();
+        }
+        return bytesWritten;
+    }
+
+    /*
+     * Indirect read/writes work on byte[]'s
+     */
+    private native long readImpl(long fileDescriptor, byte[] bytes, int offset,
+            int length);
+
+    public long read(long fileDescriptor, byte[] bytes, int offset, int length)
+            throws IOException {
+        if (bytes == null) {
+            throw new NullPointerException();
+        }
+        long bytesRead = readImpl(fileDescriptor, bytes, offset, length);
+        if (bytesRead < -1) {
                         /*
                          * TODO: bytesRead is never less than -1 so this code
                          * does nothing?
@@ -161,81 +161,81 @@
                          * any other cases.  But the other cases have been
                          * ignored until now so fixing this could break things
                          */
-			throw new IOException();
-		}
-		return bytesRead;
-	}
-
-	private native long writeImpl(long fileDescriptor, byte[] bytes,
-			int offset, int length);
-
-	public long write(long fileDescriptor, byte[] bytes, int offset, int length)
-			throws IOException {
-		long bytesWritten = writeImpl(fileDescriptor, bytes, offset, length);
-		if (bytesWritten < 0) {
-			throw new IOException();
-		}
-		return bytesWritten;
-	}
-
-	/*
-	 * Scatter/gather calls.
-	 */
-	public long readv(long fileDescriptor, long[] addresses, int[] offsets,
-			int[] lengths, int size) throws IOException {
-		long bytesRead = readvImpl(fileDescriptor, addresses, offsets, lengths,
-				size);
-		if (bytesRead < -1) {
-			throw new IOException();
-		}
-		return bytesRead;
-	}
-
-	private native long readvImpl(long fileDescriptor, long[] addresses,
-			int[] offsets, int[] lengths, int size);
-
-	public long writev(long fileDescriptor, long[] addresses, int[] offsets,
-			int[] lengths, int size) throws IOException {
-		long bytesWritten = writevImpl(fileDescriptor, addresses, offsets,
-				lengths, size);
-		if (bytesWritten < 0) {
-			throw new IOException();
-		}
-		return bytesWritten;
-	}
-
-	private native long writevImpl(long fileDescriptor, long[] addresses,
-			int[] offsets, int[] lengths, int size);
-
-	private native int closeImpl(long fileDescriptor);
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.harmony.luni.platform.IFileSystem#close(long)
-	 */
-	public void close(long fileDescriptor) throws IOException {
-		int rc = closeImpl(fileDescriptor);
-		if (rc == -1) {
-			throw new IOException();
-		}
-	}
-
-	public void truncate(long fileDescriptor, long size) throws IOException {
-		int rc = truncateImpl(fileDescriptor, size);
-		if (rc < 0) {
-			throw new IOException();
-		}
-	}
-
-	private native int truncateImpl(long fileDescriptor, long size);
-
-	public long open(byte[] fileName, int mode) throws FileNotFoundException {
-		if (fileName == null) {
-			throw new NullPointerException();
-		}
-		long handler = openImpl(fileName, mode);
-		if (handler < 0) {
+            throw new IOException();
+        }
+        return bytesRead;
+    }
+
+    private native long writeImpl(long fileDescriptor, byte[] bytes,
+            int offset, int length);
+
+    public long write(long fileDescriptor, byte[] bytes, int offset, int length)
+            throws IOException {
+        long bytesWritten = writeImpl(fileDescriptor, bytes, offset, length);
+        if (bytesWritten < 0) {
+            throw new IOException();
+        }
+        return bytesWritten;
+    }
+
+    /*
+     * Scatter/gather calls.
+     */
+    public long readv(long fileDescriptor, long[] addresses, int[] offsets,
+            int[] lengths, int size) throws IOException {
+        long bytesRead = readvImpl(fileDescriptor, addresses, offsets, lengths,
+                size);
+        if (bytesRead < -1) {
+            throw new IOException();
+        }
+        return bytesRead;
+    }
+
+    private native long readvImpl(long fileDescriptor, long[] addresses,
+            int[] offsets, int[] lengths, int size);
+
+    public long writev(long fileDescriptor, long[] addresses, int[] offsets,
+            int[] lengths, int size) throws IOException {
+        long bytesWritten = writevImpl(fileDescriptor, addresses, offsets,
+                lengths, size);
+        if (bytesWritten < 0) {
+            throw new IOException();
+        }
+        return bytesWritten;
+    }
+
+    private native long writevImpl(long fileDescriptor, long[] addresses,
+            int[] offsets, int[] lengths, int size);
+
+    private native int closeImpl(long fileDescriptor);
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.harmony.luni.platform.IFileSystem#close(long)
+     */
+    public void close(long fileDescriptor) throws IOException {
+        int rc = closeImpl(fileDescriptor);
+        if (rc == -1) {
+            throw new IOException();
+        }
+    }
+
+    public void truncate(long fileDescriptor, long size) throws IOException {
+        int rc = truncateImpl(fileDescriptor, size);
+        if (rc < 0) {
+            throw new IOException();
+        }
+    }
+
+    private native int truncateImpl(long fileDescriptor, long size);
+
+    public long open(byte[] fileName, int mode) throws FileNotFoundException {
+        if (fileName == null) {
+            throw new NullPointerException();
+        }
+        long handler = openImpl(fileName, mode);
+        if (handler < 0) {
                     try {
                         throw new FileNotFoundException(new String(fileName, "UTF-8"));
                     } catch (java.io.UnsupportedEncodingException e) {
@@ -244,40 +244,40 @@
                         e.initCause(fnfe);
                         throw new AssertionError(e);
                     }
-		}
-		return handler;
-	}
-
-	private native long openImpl(byte[] fileName, int mode);
-
-	public long transfer(long fileHandler, FileDescriptor socketDescriptor,
-			long offset, long count) throws IOException {
-		long result = transferImpl(fileHandler, socketDescriptor, offset, count);
-		if (result < 0)
-			throw new IOException();
-		return result;
-	}
-
-	private native long transferImpl(long fileHandler,
-			FileDescriptor socketDescriptor, long offset, long count);
-
-	public long ttyAvailable() throws IOException {
-		long nChar = ttyAvailableImpl();
-		if (nChar < 0) {
-			throw new IOException();
-		}
-		return nChar;
-	}
-
-	private native long ttyAvailableImpl();
-
-	public long ttyRead(byte[] bytes, int offset, int length) throws IOException {
-		long nChar = ttyReadImpl(bytes, offset, length);
-		if (nChar < 0) {
-			throw new IOException();
-		}
-		return nChar;
-	}
+        }
+        return handler;
+    }
+
+    private native long openImpl(byte[] fileName, int mode);
+
+    public long transfer(long fileHandler, FileDescriptor socketDescriptor,
+            long offset, long count) throws IOException {
+        long result = transferImpl(fileHandler, socketDescriptor, offset, count);
+        if (result < 0)
+            throw new IOException();
+        return result;
+    }
+
+    private native long transferImpl(long fileHandler,
+            FileDescriptor socketDescriptor, long offset, long count);
+
+    public long ttyAvailable() throws IOException {
+        long nChar = ttyAvailableImpl();
+        if (nChar < 0) {
+            throw new IOException();
+        }
+        return nChar;
+    }
+
+    private native long ttyAvailableImpl();
+
+    public long ttyRead(byte[] bytes, int offset, int length) throws IOException {
+        long nChar = ttyReadImpl(bytes, offset, length);
+        if (nChar < 0) {
+            throw new IOException();
+        }
+        return nChar;
+    }
 
-	private native long ttyReadImpl(byte[] bytes, int offset, int length);
+    private native long ttyReadImpl(byte[] bytes, int offset, int length);
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/platform/OSMemory.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/platform/OSMemory.java?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/platform/OSMemory.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/platform/OSMemory.java Thu Nov 26 11:12:49 2009
@@ -41,33 +41,33 @@
  */
 final class OSMemory implements IMemorySystem {
 
-	/**
-	 * Defines the size, in bytes, of a native pointer type for the underlying
-	 * platform. This will be 4 (for 32-bit machines) or 8 (for 64-bit
-	 * machines).
-	 */
-	public static final int POINTER_SIZE;
-
-	/**
-	 * Defines the natural byte order for this machine.
-	 */
-	public static final Endianness NATIVE_ORDER;
-
-	private static final OSMemory singleton = new OSMemory();
-
-	static {
-		POINTER_SIZE = getPointerSizeImpl();
-
-		if (isLittleEndianImpl()) {
-			NATIVE_ORDER = Endianness.LITTLE_ENDIAN;
-		} else {
-			NATIVE_ORDER = Endianness.BIG_ENDIAN;
-		}
-	}
-
-	public static OSMemory getOSMemory() {
-		return singleton;
-	}
+    /**
+     * Defines the size, in bytes, of a native pointer type for the underlying
+     * platform. This will be 4 (for 32-bit machines) or 8 (for 64-bit
+     * machines).
+     */
+    public static final int POINTER_SIZE;
+
+    /**
+     * Defines the natural byte order for this machine.
+     */
+    public static final Endianness NATIVE_ORDER;
+
+    private static final OSMemory singleton = new OSMemory();
+
+    static {
+        POINTER_SIZE = getPointerSizeImpl();
+
+        if (isLittleEndianImpl()) {
+            NATIVE_ORDER = Endianness.LITTLE_ENDIAN;
+        } else {
+            NATIVE_ORDER = Endianness.BIG_ENDIAN;
+        }
+    }
+
+    public static OSMemory getOSMemory() {
+        return singleton;
+    }
 
     /*
      * Native method to determine whether the underlying platform is little
@@ -78,14 +78,14 @@
      */
     private static native boolean isLittleEndianImpl();
 
-	/**
-	 * This class is not designed to be publicly instantiated.
-	 * 
-	 * @see #getOSMemory()
-	 */
-	private OSMemory() {
-		super();
-	}
+    /**
+     * This class is not designed to be publicly instantiated.
+     * 
+     * @see #getOSMemory()
+     */
+    private OSMemory() {
+        super();
+    }
 
     /**
      * Answers whether the byte order of this machine is little endian or not.
@@ -93,510 +93,510 @@
      * @return <code>false</code> for Big Endian, and
      *         <code>true</code> for Little Endian.
      */
-	public boolean isLittleEndian() {
-		return NATIVE_ORDER == Endianness.LITTLE_ENDIAN;
-	}
-
-	/**
-	 * Answers the natural byte order for this machine.
-	 * 
-	 * @return the native byte order for the current platform.
-	 */
-	public Endianness getNativeOrder() {
-		return NATIVE_ORDER;
-	}
-
-	/**
-	 * Answers the size of a native pointer type for the underlying platform.
-	 * 
-	 * @return the size of a pointer, in bytes.
-	 */
-	private static native int getPointerSizeImpl();
-
-	public int getPointerSize() {
-		return POINTER_SIZE;
-	}
-
-	/**
-	 * Allocates and returns a pointer to space for a memory block of
-	 * <code>length</code> bytes. The space is uninitialized and may be larger
-	 * than the number of bytes requested; however, the guaranteed usable memory
-	 * block is exactly <code>length</code> bytes long.
-	 * 
-	 * @param length
-	 *            number of bytes requested.
-	 * @return the address of the start of the memory block.
-	 * @throws OutOfMemoryError
-	 *             if the request cannot be satisfied.
-	 */
-	public native long malloc(long length) throws OutOfMemoryError;
-
-	/**
-	 * Deallocates space for a memory block that was previously allocated by a
-	 * call to {@link #malloc(long) malloc(long)}. The number of bytes freed is
-	 * identical to the number of bytes acquired when the memory block was
-	 * allocated. If <code>address</code> is zero the method does nothing.
-	 * <p>
-	 * Freeing a pointer to a memory block that was not allocated by
-	 * <code>malloc()</code> has unspecified effect.
-	 * </p>
-	 * 
-	 * @param address
-	 *            the address of the memory block to deallocate.
-	 */
-	public native void free(long address);
-
-	/**
-	 * Places <code>value</code> into first <code>length</code> bytes of the
-	 * memory block starting at <code>address</code>.
-	 * <p>
-	 * The behavior is unspecified if
-	 * <code>(address ... address + length)</code> is not wholly within the
-	 * range that was previously allocated using <code>malloc()</code>.
-	 * </p>
-	 * 
-	 * @param address
-	 *            the address of the first memory location.
-	 * @param value
-	 *            the byte value to set at each location.
-	 * @param length
-	 *            the number of byte-length locations to set.
-	 */
-	public native void memset(long address, byte value, long length);
-
-	/**
-	 * Copies <code>length</code> bytes from <code>srcAddress</code> to
-	 * <code>destAddress</code>. Where any part of the source memory block
-	 * and the destination memory block overlap <code>memmove()</code> ensures
-	 * that the original source bytes in the overlapping region are copied
-	 * before being overwritten.
-	 * <p>
-	 * The behavior is unspecified if
-	 * <code>(srcAddress ... srcAddress + length)</code> and
-	 * <code>(destAddress ... destAddress + length)</code> are not both wholly
-	 * within the range that was previously allocated using
-	 * <code>malloc()</code>.
-	 * </p>
-	 * 
-	 * @param destAddress
-	 *            the address of the destination memory block.
-	 * @param srcAddress
-	 *            the address of the source memory block.
-	 * @param length
-	 *            the number of bytes to move.
-	 */
-	public native void memmove(long destAddress, long srcAddress, long length);
-
-	/**
-	 * Copies <code>length</code> bytes from the memory block at
-	 * <code>address</code> into the byte array <code>bytes</code> starting
-	 * at element <code>offset</code> within the byte array.
-	 * <p>
-	 * The behavior of this method is undefined if the range
-	 * <code>(address ... address + length)</code> is not within a memory
-	 * block that was allocated using {@link #malloc(long) malloc(long)}.
-	 * </p>
-	 * 
-	 * @param address
-	 *            the address of the OS memory block from which to copy bytes.
-	 * @param bytes
-	 *            the byte array into which to copy the bytes.
-	 * @param offset
-	 *            the index of the first element in <code>bytes</code> that
-	 *            will be overwritten.
-	 * @param length
-	 *            the total number of bytes to copy into the byte array.
-	 * @throws NullPointerException
-	 *             if <code>bytes</code> is <code>null</code>.
-	 * @throws IndexOutOfBoundsException
-	 *             if <code>offset + length > bytes.length</code>.
-	 */
-	public native void getByteArray(long address, byte[] bytes, int offset,
-			int length) throws NullPointerException, IndexOutOfBoundsException;
-
-	/**
-	 * Copies <code>length</code> bytes from the byte array <code>bytes</code>
-	 * into the memory block at <code>address</code>, starting at element
-	 * <code>offset</code> within the byte array.
-	 * <p>
-	 * The behavior of this method is undefined if the range
-	 * <code>(address ... address + length)</code> is not within a memory
-	 * block that was allocated using {@link #malloc(long) malloc(long)}.
-	 * </p>
-	 * 
-	 * @param address
-	 *            the address of the OS memory block into which to copy the
-	 *            bytes.
-	 * @param bytes
-	 *            the byte array from which to copy the bytes.
-	 * @param offset
-	 *            the index of the first element in <code>bytes</code> that
-	 *            will be read.
-	 * @param length
-	 *            the total number of bytes to copy from <code>bytes</code>
-	 *            into the memory block.
-	 * @throws NullPointerException
-	 *             if <code>bytes</code> is <code>null</code>.
-	 * @throws IndexOutOfBoundsException
-	 *             if <code>offset + length > bytes.length</code>.
-	 */
-	public native void setByteArray(long address, byte[] bytes, int offset,
-			int length) throws NullPointerException, IndexOutOfBoundsException;
-
-	// Primitive get & set methods
-
-	/**
-	 * Gets the value of the single byte at the given address.
-	 * <p>
-	 * The behavior is unspecified if <code>address</code> is not in the range
-	 * that was previously allocated using <code>malloc()</code>.
-	 * </p>
-	 * 
-	 * @param address
-	 *            the platform address of the byte.
-	 * @return the byte value.
-	 */
-	public native byte getByte(long address);
-
-	/**
-	 * Sets the given single byte value at the given address.
-	 * <p>
-	 * The behavior is unspecified if <code>address</code> is not in the range
-	 * that was previously allocated using <code>malloc()</code>.
-	 * </p>
-	 * 
-	 * @param address
-	 *            the address at which to set the byte value.
-	 * @param value
-	 *            the value to set.
-	 */
-	public native void setByte(long address, byte value);
-
-	/**
-	 * Gets the value of the signed two-byte integer stored in platform byte
-	 * order at the given address.
-	 * <p>
-	 * The behavior is unspecified if <code>(address ... address + 2)</code>
-	 * is not wholly within the range that was previously allocated using
-	 * <code>malloc()</code>.
-	 * </p>
-	 * 
-	 * @param address
-	 *            the platform address of the start of the two-byte value.
-	 * @return the value of the two-byte integer as a Java <code>short</code>.
-	 */
-	public native short getShort(long address);
-
-	public short getShort(long address, Endianness endianness) {
-		return (endianness == NATIVE_ORDER) ? getShort(address)
-				: swap(getShort(address));
-	}
-
-	/**
-	 * Sets the value of the signed two-byte integer at the given address in
-	 * platform byte order.
-	 * <p>
-	 * The behavior is unspecified if <code>(address ... address + 2)</code>
-	 * is not wholly within the range that was previously allocated using
-	 * <code>malloc()</code>.
-	 * </p>
-	 * 
-	 * @param address
-	 *            the platform address of the start of the two-byte value.
-	 * @param value
-	 *            the value of the two-byte integer as a Java <code>short</code>.
-	 */
-	public native void setShort(long address, short value);
-
-	public void setShort(long address, short value, Endianness endianness) {
-		if (endianness == NATIVE_ORDER) {
-			setShort(address, value);
-		} else {
-			setShort(address, swap(value));
-		}
-	}
-
-	/**
-	 * Gets the value of the signed four-byte integer stored in platform
-	 * byte-order at the given address.
-	 * <p>
-	 * The behavior is unspecified if <code>(address ... address + 4)</code>
-	 * is not wholly within the range that was previously allocated using
-	 * <code>malloc()</code>.
-	 * </p>
-	 * 
-	 * @param address
-	 *            the platform address of the start of the four-byte value.
-	 * @return the value of the four-byte integer as a Java <code>int</code>.
-	 */
-	public native int getInt(long address);
-
-	public int getInt(long address, Endianness endianness) {
-		return (endianness == NATIVE_ORDER) ? getInt(address)
-				: swap(getInt(address));
-	}
-
-	/**
-	 * Sets the value of the signed four-byte integer at the given address in
-	 * platform byte order.
-	 * <p>
-	 * The behavior is unspecified if <code>(address ... address + 4)</code>
-	 * is not wholly within the range that was previously allocated using
-	 * <code>malloc()</code>.
-	 * </p>
-	 * 
-	 * @param address
-	 *            the platform address of the start of the four-byte value.
-	 * @param value
-	 *            the value of the four-byte integer as a Java <code>int</code>.
-	 */
-	public native void setInt(long address, int value);
-
-	public void setInt(long address, int value, Endianness endianness) {
-		if (endianness == NATIVE_ORDER) {
-			setInt(address, value);
-		} else {
-			setInt(address, swap(value));
-		}
-	}
-
-	/**
-	 * Gets the value of the signed eight-byte integer stored in platform byte
-	 * order at the given address.
-	 * <p>
-	 * The behavior is unspecified if <code>(address ... address + 8)</code>
-	 * is not wholly within the range that was previously allocated using
-	 * <code>malloc()</code>.
-	 * </p>
-	 * 
-	 * @param address
-	 *            the platform address of the start of the eight-byte value.
-	 * @return the value of the eight-byte integer as a Java <code>long</code>.
-	 */
-	public native long getLong(long address);
-
-	public long getLong(long address, Endianness endianness) {
-		return (endianness == NATIVE_ORDER) ? getLong(address)
-				: swap(getLong(address));
-	}
-
-	/**
-	 * Sets the value of the signed eight-byte integer at the given address in
-	 * the platform byte order.
-	 * <p>
-	 * The behavior is unspecified if <code>(address ... address + 8)</code>
-	 * is not wholly within the range that was previously allocated using
-	 * <code>malloc()</code>.
-	 * </p>
-	 * 
-	 * @param address
-	 *            the platform address of the start of the eight-byte value.
-	 * @param value
-	 *            the value of the eight-byte integer as a Java
-	 *            <code>long</code>.
-	 */
-	public native void setLong(long address, long value);
-
-	public void setLong(long address, long value, Endianness endianness) {
-		if (endianness == NATIVE_ORDER) {
-			setLong(address, value);
-		} else {
-			setLong(address, swap(value));
-		}
-	}
-
-	/**
-	 * Gets the value of the IEEE754-format four-byte float stored in platform
-	 * byte order at the given address.
-	 * <p>
-	 * The behavior is unspecified if <code>(address ... address + 4)</code>
-	 * is not wholly within the range that was previously allocated using
-	 * <code>malloc()</code>.
-	 * </p>
-	 * 
-	 * @param address
-	 *            the platform address of the start of the eight-byte value.
-	 * @return the value of the four-byte float as a Java <code>float</code>.
-	 */
-	public native float getFloat(long address);
-
-	public float getFloat(long address, Endianness endianness) {
-		if (endianness == NATIVE_ORDER) {
-			return getFloat(address);
-		}
-		int floatBits = swap(getInt(address));
-		return Float.intBitsToFloat(floatBits);
-	}
-
-	/**
-	 * Sets the value of the IEEE754-format four-byte float stored in platform
-	 * byte order at the given address.
-	 * <p>
-	 * The behavior is unspecified if <code>(address ... address + 4)</code>
-	 * is not wholly within the range that was previously allocated using
-	 * <code>malloc()</code>.
-	 * </p>
-	 * 
-	 * @param address
-	 *            the platform address of the start of the eight-byte value.
-	 * @param value
-	 *            the value of the four-byte float as a Java <code>float</code>.
-	 */
-	public native void setFloat(long address, float value);
-
-	public void setFloat(long address, float value, Endianness endianness) {
-		if (endianness == NATIVE_ORDER) {
-			setFloat(address, value);
-		} else {
-			int floatBits = Float.floatToIntBits(value);
-			setInt(address, swap(floatBits));
-		}
-	}
-
-	/**
-	 * Gets the value of the IEEE754-format eight-byte float stored in platform
-	 * byte order at the given address.
-	 * <p>
-	 * The behavior is unspecified if <code>(address ... address + 8)</code>
-	 * is not wholly within the range that was previously allocated using
-	 * <code>malloc()</code>.
-	 * </p>
-	 * 
-	 * @param address
-	 *            the platform address of the start of the eight-byte value.
-	 * @return the value of the eight-byte float as a Java <code>double</code>.
-	 */
-	public native double getDouble(long address);
-
-	public double getDouble(long address, Endianness endianness) {
-		if (endianness == NATIVE_ORDER) {
-			return getDouble(address);
-		}
-		long doubleBits = swap(getLong(address));
-		return Double.longBitsToDouble(doubleBits);
-	}
-
-	/**
-	 * Sets the value of the IEEE754-format eight-byte float store in platform
-	 * byte order at the given address.
-	 * <p>
-	 * The behavior is unspecified if <code>(address ... address + 8)</code>
-	 * is not wholly within the range that was previously allocated using
-	 * <code>malloc()</code>.
-	 * </p>
-	 * 
-	 * @param address
-	 *            the platform address of the start of the eight-byte value.
-	 * @param value
-	 *            the value of the eight-byte float as a Java
-	 *            <code>double</code>.
-	 */
-	public native void setDouble(long address, double value);
-
-	public void setDouble(long address, double value, Endianness endianness) {
-		if (endianness == NATIVE_ORDER) {
-			setDouble(address, value);
-		} else {
-			long doubleBits = Double.doubleToLongBits(value);
-			setLong(address, swap(doubleBits));
-		}
-	}
-
-	/**
-	 * Gets the value of the platform pointer at the given address.
-	 * <p>
-	 * The length of the platform pointer is defined by
-	 * <code>POINTER_SIZE</code>.
-	 * </p>
-	 * The behavior is unspecified if
-	 * <code>(address ... address + POINTER_SIZE)</code> is not wholly within
-	 * the range that was previously allocated using <code>malloc()</code>.
-	 * </p>
-	 * 
-	 * @param address
-	 *            the platform address of the start of the platform pointer.
-	 * @return the value of the platform pointer as a Java <code>long</code>.
-	 */
-	public native long getAddress(long address);
-
-	/**
-	 * Sets the value of the platform pointer at the given address.
-	 * <p>
-	 * The length of the platform pointer is defined by
-	 * <code>POINTER_SIZE</code>. This method only sets
-	 * <code>POINTER_SIZE</code> bytes at the given address.
-	 * </p>
-	 * The behavior is unspecified if
-	 * <code>(address ... address + POINTER_SIZE)</code> is not wholly within
-	 * the range that was previously allocated using <code>malloc()</code>.
-	 * </p>
-	 * 
-	 * @param address
-	 *            the platform address of the start of the platform pointer.
-	 * @param value
-	 *            the value of the platform pointer as a Java <code>long</code>.
-	 */
-	public native void setAddress(long address, long value);
-
-	/*
-	 * Memory mapped file
-	 */
-	private native long mmapImpl(long fileDescriptor, long alignment,
-			long size, int mapMode);
+    public boolean isLittleEndian() {
+        return NATIVE_ORDER == Endianness.LITTLE_ENDIAN;
+    }
+
+    /**
+     * Answers the natural byte order for this machine.
+     * 
+     * @return the native byte order for the current platform.
+     */
+    public Endianness getNativeOrder() {
+        return NATIVE_ORDER;
+    }
+
+    /**
+     * Answers the size of a native pointer type for the underlying platform.
+     * 
+     * @return the size of a pointer, in bytes.
+     */
+    private static native int getPointerSizeImpl();
+
+    public int getPointerSize() {
+        return POINTER_SIZE;
+    }
+
+    /**
+     * Allocates and returns a pointer to space for a memory block of
+     * <code>length</code> bytes. The space is uninitialized and may be larger
+     * than the number of bytes requested; however, the guaranteed usable memory
+     * block is exactly <code>length</code> bytes long.
+     * 
+     * @param length
+     *            number of bytes requested.
+     * @return the address of the start of the memory block.
+     * @throws OutOfMemoryError
+     *             if the request cannot be satisfied.
+     */
+    public native long malloc(long length) throws OutOfMemoryError;
+
+    /**
+     * Deallocates space for a memory block that was previously allocated by a
+     * call to {@link #malloc(long) malloc(long)}. The number of bytes freed is
+     * identical to the number of bytes acquired when the memory block was
+     * allocated. If <code>address</code> is zero the method does nothing.
+     * <p>
+     * Freeing a pointer to a memory block that was not allocated by
+     * <code>malloc()</code> has unspecified effect.
+     * </p>
+     * 
+     * @param address
+     *            the address of the memory block to deallocate.
+     */
+    public native void free(long address);
+
+    /**
+     * Places <code>value</code> into first <code>length</code> bytes of the
+     * memory block starting at <code>address</code>.
+     * <p>
+     * The behavior is unspecified if
+     * <code>(address ... address + length)</code> is not wholly within the
+     * range that was previously allocated using <code>malloc()</code>.
+     * </p>
+     * 
+     * @param address
+     *            the address of the first memory location.
+     * @param value
+     *            the byte value to set at each location.
+     * @param length
+     *            the number of byte-length locations to set.
+     */
+    public native void memset(long address, byte value, long length);
+
+    /**
+     * Copies <code>length</code> bytes from <code>srcAddress</code> to
+     * <code>destAddress</code>. Where any part of the source memory block
+     * and the destination memory block overlap <code>memmove()</code> ensures
+     * that the original source bytes in the overlapping region are copied
+     * before being overwritten.
+     * <p>
+     * The behavior is unspecified if
+     * <code>(srcAddress ... srcAddress + length)</code> and
+     * <code>(destAddress ... destAddress + length)</code> are not both wholly
+     * within the range that was previously allocated using
+     * <code>malloc()</code>.
+     * </p>
+     * 
+     * @param destAddress
+     *            the address of the destination memory block.
+     * @param srcAddress
+     *            the address of the source memory block.
+     * @param length
+     *            the number of bytes to move.
+     */
+    public native void memmove(long destAddress, long srcAddress, long length);
+
+    /**
+     * Copies <code>length</code> bytes from the memory block at
+     * <code>address</code> into the byte array <code>bytes</code> starting
+     * at element <code>offset</code> within the byte array.
+     * <p>
+     * The behavior of this method is undefined if the range
+     * <code>(address ... address + length)</code> is not within a memory
+     * block that was allocated using {@link #malloc(long) malloc(long)}.
+     * </p>
+     * 
+     * @param address
+     *            the address of the OS memory block from which to copy bytes.
+     * @param bytes
+     *            the byte array into which to copy the bytes.
+     * @param offset
+     *            the index of the first element in <code>bytes</code> that
+     *            will be overwritten.
+     * @param length
+     *            the total number of bytes to copy into the byte array.
+     * @throws NullPointerException
+     *             if <code>bytes</code> is <code>null</code>.
+     * @throws IndexOutOfBoundsException
+     *             if <code>offset + length > bytes.length</code>.
+     */
+    public native void getByteArray(long address, byte[] bytes, int offset,
+            int length) throws NullPointerException, IndexOutOfBoundsException;
+
+    /**
+     * Copies <code>length</code> bytes from the byte array <code>bytes</code>
+     * into the memory block at <code>address</code>, starting at element
+     * <code>offset</code> within the byte array.
+     * <p>
+     * The behavior of this method is undefined if the range
+     * <code>(address ... address + length)</code> is not within a memory
+     * block that was allocated using {@link #malloc(long) malloc(long)}.
+     * </p>
+     * 
+     * @param address
+     *            the address of the OS memory block into which to copy the
+     *            bytes.
+     * @param bytes
+     *            the byte array from which to copy the bytes.
+     * @param offset
+     *            the index of the first element in <code>bytes</code> that
+     *            will be read.
+     * @param length
+     *            the total number of bytes to copy from <code>bytes</code>
+     *            into the memory block.
+     * @throws NullPointerException
+     *             if <code>bytes</code> is <code>null</code>.
+     * @throws IndexOutOfBoundsException
+     *             if <code>offset + length > bytes.length</code>.
+     */
+    public native void setByteArray(long address, byte[] bytes, int offset,
+            int length) throws NullPointerException, IndexOutOfBoundsException;
+
+    // Primitive get & set methods
+
+    /**
+     * Gets the value of the single byte at the given address.
+     * <p>
+     * The behavior is unspecified if <code>address</code> is not in the range
+     * that was previously allocated using <code>malloc()</code>.
+     * </p>
+     * 
+     * @param address
+     *            the platform address of the byte.
+     * @return the byte value.
+     */
+    public native byte getByte(long address);
+
+    /**
+     * Sets the given single byte value at the given address.
+     * <p>
+     * The behavior is unspecified if <code>address</code> is not in the range
+     * that was previously allocated using <code>malloc()</code>.
+     * </p>
+     * 
+     * @param address
+     *            the address at which to set the byte value.
+     * @param value
+     *            the value to set.
+     */
+    public native void setByte(long address, byte value);
+
+    /**
+     * Gets the value of the signed two-byte integer stored in platform byte
+     * order at the given address.
+     * <p>
+     * The behavior is unspecified if <code>(address ... address + 2)</code>
+     * is not wholly within the range that was previously allocated using
+     * <code>malloc()</code>.
+     * </p>
+     * 
+     * @param address
+     *            the platform address of the start of the two-byte value.
+     * @return the value of the two-byte integer as a Java <code>short</code>.
+     */
+    public native short getShort(long address);
+
+    public short getShort(long address, Endianness endianness) {
+        return (endianness == NATIVE_ORDER) ? getShort(address)
+                : swap(getShort(address));
+    }
+
+    /**
+     * Sets the value of the signed two-byte integer at the given address in
+     * platform byte order.
+     * <p>
+     * The behavior is unspecified if <code>(address ... address + 2)</code>
+     * is not wholly within the range that was previously allocated using
+     * <code>malloc()</code>.
+     * </p>
+     * 
+     * @param address
+     *            the platform address of the start of the two-byte value.
+     * @param value
+     *            the value of the two-byte integer as a Java <code>short</code>.
+     */
+    public native void setShort(long address, short value);
+
+    public void setShort(long address, short value, Endianness endianness) {
+        if (endianness == NATIVE_ORDER) {
+            setShort(address, value);
+        } else {
+            setShort(address, swap(value));
+        }
+    }
 
-	public long mmap(long fileDescriptor, long alignment, long size,
-			int mapMode) throws IOException {
+    /**
+     * Gets the value of the signed four-byte integer stored in platform
+     * byte-order at the given address.
+     * <p>
+     * The behavior is unspecified if <code>(address ... address + 4)</code>
+     * is not wholly within the range that was previously allocated using
+     * <code>malloc()</code>.
+     * </p>
+     * 
+     * @param address
+     *            the platform address of the start of the four-byte value.
+     * @return the value of the four-byte integer as a Java <code>int</code>.
+     */
+    public native int getInt(long address);
+
+    public int getInt(long address, Endianness endianness) {
+        return (endianness == NATIVE_ORDER) ? getInt(address)
+                : swap(getInt(address));
+    }
+
+    /**
+     * Sets the value of the signed four-byte integer at the given address in
+     * platform byte order.
+     * <p>
+     * The behavior is unspecified if <code>(address ... address + 4)</code>
+     * is not wholly within the range that was previously allocated using
+     * <code>malloc()</code>.
+     * </p>
+     * 
+     * @param address
+     *            the platform address of the start of the four-byte value.
+     * @param value
+     *            the value of the four-byte integer as a Java <code>int</code>.
+     */
+    public native void setInt(long address, int value);
+
+    public void setInt(long address, int value, Endianness endianness) {
+        if (endianness == NATIVE_ORDER) {
+            setInt(address, value);
+        } else {
+            setInt(address, swap(value));
+        }
+    }
+
+    /**
+     * Gets the value of the signed eight-byte integer stored in platform byte
+     * order at the given address.
+     * <p>
+     * The behavior is unspecified if <code>(address ... address + 8)</code>
+     * is not wholly within the range that was previously allocated using
+     * <code>malloc()</code>.
+     * </p>
+     * 
+     * @param address
+     *            the platform address of the start of the eight-byte value.
+     * @return the value of the eight-byte integer as a Java <code>long</code>.
+     */
+    public native long getLong(long address);
+
+    public long getLong(long address, Endianness endianness) {
+        return (endianness == NATIVE_ORDER) ? getLong(address)
+                : swap(getLong(address));
+    }
+
+    /**
+     * Sets the value of the signed eight-byte integer at the given address in
+     * the platform byte order.
+     * <p>
+     * The behavior is unspecified if <code>(address ... address + 8)</code>
+     * is not wholly within the range that was previously allocated using
+     * <code>malloc()</code>.
+     * </p>
+     * 
+     * @param address
+     *            the platform address of the start of the eight-byte value.
+     * @param value
+     *            the value of the eight-byte integer as a Java
+     *            <code>long</code>.
+     */
+    public native void setLong(long address, long value);
+
+    public void setLong(long address, long value, Endianness endianness) {
+        if (endianness == NATIVE_ORDER) {
+            setLong(address, value);
+        } else {
+            setLong(address, swap(value));
+        }
+    }
+
+    /**
+     * Gets the value of the IEEE754-format four-byte float stored in platform
+     * byte order at the given address.
+     * <p>
+     * The behavior is unspecified if <code>(address ... address + 4)</code>
+     * is not wholly within the range that was previously allocated using
+     * <code>malloc()</code>.
+     * </p>
+     * 
+     * @param address
+     *            the platform address of the start of the eight-byte value.
+     * @return the value of the four-byte float as a Java <code>float</code>.
+     */
+    public native float getFloat(long address);
+
+    public float getFloat(long address, Endianness endianness) {
+        if (endianness == NATIVE_ORDER) {
+            return getFloat(address);
+        }
+        int floatBits = swap(getInt(address));
+        return Float.intBitsToFloat(floatBits);
+    }
+
+    /**
+     * Sets the value of the IEEE754-format four-byte float stored in platform
+     * byte order at the given address.
+     * <p>
+     * The behavior is unspecified if <code>(address ... address + 4)</code>
+     * is not wholly within the range that was previously allocated using
+     * <code>malloc()</code>.
+     * </p>
+     * 
+     * @param address
+     *            the platform address of the start of the eight-byte value.
+     * @param value
+     *            the value of the four-byte float as a Java <code>float</code>.
+     */
+    public native void setFloat(long address, float value);
+
+    public void setFloat(long address, float value, Endianness endianness) {
+        if (endianness == NATIVE_ORDER) {
+            setFloat(address, value);
+        } else {
+            int floatBits = Float.floatToIntBits(value);
+            setInt(address, swap(floatBits));
+        }
+    }
+
+    /**
+     * Gets the value of the IEEE754-format eight-byte float stored in platform
+     * byte order at the given address.
+     * <p>
+     * The behavior is unspecified if <code>(address ... address + 8)</code>
+     * is not wholly within the range that was previously allocated using
+     * <code>malloc()</code>.
+     * </p>
+     * 
+     * @param address
+     *            the platform address of the start of the eight-byte value.
+     * @return the value of the eight-byte float as a Java <code>double</code>.
+     */
+    public native double getDouble(long address);
+
+    public double getDouble(long address, Endianness endianness) {
+        if (endianness == NATIVE_ORDER) {
+            return getDouble(address);
+        }
+        long doubleBits = swap(getLong(address));
+        return Double.longBitsToDouble(doubleBits);
+    }
+
+    /**
+     * Sets the value of the IEEE754-format eight-byte float store in platform
+     * byte order at the given address.
+     * <p>
+     * The behavior is unspecified if <code>(address ... address + 8)</code>
+     * is not wholly within the range that was previously allocated using
+     * <code>malloc()</code>.
+     * </p>
+     * 
+     * @param address
+     *            the platform address of the start of the eight-byte value.
+     * @param value
+     *            the value of the eight-byte float as a Java
+     *            <code>double</code>.
+     */
+    public native void setDouble(long address, double value);
+
+    public void setDouble(long address, double value, Endianness endianness) {
+        if (endianness == NATIVE_ORDER) {
+            setDouble(address, value);
+        } else {
+            long doubleBits = Double.doubleToLongBits(value);
+            setLong(address, swap(doubleBits));
+        }
+    }
+
+    /**
+     * Gets the value of the platform pointer at the given address.
+     * <p>
+     * The length of the platform pointer is defined by
+     * <code>POINTER_SIZE</code>.
+     * </p>
+     * The behavior is unspecified if
+     * <code>(address ... address + POINTER_SIZE)</code> is not wholly within
+     * the range that was previously allocated using <code>malloc()</code>.
+     * </p>
+     * 
+     * @param address
+     *            the platform address of the start of the platform pointer.
+     * @return the value of the platform pointer as a Java <code>long</code>.
+     */
+    public native long getAddress(long address);
+
+    /**
+     * Sets the value of the platform pointer at the given address.
+     * <p>
+     * The length of the platform pointer is defined by
+     * <code>POINTER_SIZE</code>. This method only sets
+     * <code>POINTER_SIZE</code> bytes at the given address.
+     * </p>
+     * The behavior is unspecified if
+     * <code>(address ... address + POINTER_SIZE)</code> is not wholly within
+     * the range that was previously allocated using <code>malloc()</code>.
+     * </p>
+     * 
+     * @param address
+     *            the platform address of the start of the platform pointer.
+     * @param value
+     *            the value of the platform pointer as a Java <code>long</code>.
+     */
+    public native void setAddress(long address, long value);
+
+    /*
+     * Memory mapped file
+     */
+    private native long mmapImpl(long fileDescriptor, long alignment,
+            long size, int mapMode);
+
+    public long mmap(long fileDescriptor, long alignment, long size,
+            int mapMode) throws IOException {
                 // No need to check mmapImpl return as it throws IOException in error cases
-		long address = mmapImpl(fileDescriptor, alignment, size, mapMode);
-		return address;
-	}
-
-	private native void unmapImpl(long addr, long size);
-
-	public void unmap(long addr, long size) {
-		unmapImpl(addr, size);
-	}
-
-	public void load(long addr, long size) {
-		loadImpl(addr, size);
-	}
-
-	private native int loadImpl(long l, long size);
-
-	public boolean isLoaded(long addr, long size) {
-		return size == 0 ? true : isLoadedImpl(addr, size);
-	}
-
-	private native boolean isLoadedImpl(long l, long size);
-
-	public void flush(long addr, long size) {
-		flushImpl(addr, size);
-	}
-
-	private native int flushImpl(long l, long size);
-
-	/*
-	 * Helper methods to change byte order.
-	 */
-	private short swap(short value) {
-		int topEnd = value << 8;
-		int btmEnd = (value >> 8) & 0xFF;
-		return (short) (topEnd | btmEnd);
-	}
-
-	private int swap(int value) {
-		short left = (short) (value >> 16);
-		short right = (short) value;
-		int topEnd = swap(right) << 16;
-		int btmEnd = swap(left) & 0xFFFF;
-		return topEnd | btmEnd;
-	}
-
-	private long swap(long value) {
-		int left = (int) (value >> 32);
-		int right = (int) value;
-		long topEnd = ((long) swap(right)) << 32;
-		long btmEnd = swap(left) & 0xFFFFFFFFL;
-		return topEnd | btmEnd;
-	}
+        long address = mmapImpl(fileDescriptor, alignment, size, mapMode);
+        return address;
+    }
+
+    private native void unmapImpl(long addr, long size);
+
+    public void unmap(long addr, long size) {
+        unmapImpl(addr, size);
+    }
+
+    public void load(long addr, long size) {
+        loadImpl(addr, size);
+    }
+
+    private native int loadImpl(long l, long size);
+
+    public boolean isLoaded(long addr, long size) {
+        return size == 0 ? true : isLoadedImpl(addr, size);
+    }
+
+    private native boolean isLoadedImpl(long l, long size);
+
+    public void flush(long addr, long size) {
+        flushImpl(addr, size);
+    }
+
+    private native int flushImpl(long l, long size);
+
+    /*
+     * Helper methods to change byte order.
+     */
+    private short swap(short value) {
+        int topEnd = value << 8;
+        int btmEnd = (value >> 8) & 0xFF;
+        return (short) (topEnd | btmEnd);
+    }
+
+    private int swap(int value) {
+        short left = (short) (value >> 16);
+        short right = (short) value;
+        int topEnd = swap(right) << 16;
+        int btmEnd = swap(left) & 0xFFFF;
+        return topEnd | btmEnd;
+    }
+
+    private long swap(long value) {
+        int left = (int) (value >> 32);
+        int right = (int) value;
+        long topEnd = ((long) swap(right)) << 32;
+        long btmEnd = swap(left) & 0xFFFFFFFFL;
+        return topEnd | btmEnd;
+    }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/platform/OSNetworkSystem.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/platform/OSNetworkSystem.java?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/platform/OSNetworkSystem.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/platform/OSNetworkSystem.java Thu Nov 26 11:12:49 2009
@@ -327,51 +327,29 @@
             DatagramPacket packet, long address, int offset, int length,
             int receiveTimeout, boolean peek) throws IOException;
 
-    /**
-     * Select the given file descriptors for read and write operations.
-     * 
-     * The file descriptors passed in as readFDs will be selected for read-ready
-     * operations, and those in the writeFDs will be selected for write-ready
-     * operations. A file descriptor can appear in either or both array, and
-     * must not be <code>null</code>. If the file descriptor is closed during
-     * the select the behavior depends upon the underlying OS.
-     * 
-     * Upon return the result is a single array of length
-     * <code>readFDs.length</code> + <code>writeFDs.length</code> laid out as
-     * the result of the select operation on the corresponding file descriptors.
-     * 
-     * @param readFDs
-     *            all sockets interested in read and accept
-     * @param writeFDs
-     *            all sockets interested in write and connect
-     * @param timeout
-     *            timeout in milliseconds
-     * @return each element describes the corresponding state of the descriptor
-     *         in the read and write arrays.
-     * @throws SocketException
-     */
-    public int[] select(FileDescriptor[] readFDs, FileDescriptor[] writeFDs,
-            long timeout) throws SocketException {
-        int countRead = readFDs.length;
-        int countWrite = writeFDs.length;
-        int result = 0;
-        if (0 == countRead + countWrite) {
-            return (new int[0]);
+
+    public boolean select(FileDescriptor[] readFDs, FileDescriptor[] writeFDs,
+            int numReadable, int numWritable, long timeout, int[] flags)
+            throws SocketException {
+        if (numReadable < 0 || numWritable < 0) {
+            throw new IllegalArgumentException();
         }
-        int[] flags = new int[countRead + countWrite];
 
-        assert validateFDs(readFDs, writeFDs) : "Invalid file descriptor arrays"; //$NON-NLS-1$
+        int total = numReadable + numWritable;
+        if (total == 0) {
+            return true;
+        }
 
-        // handle timeout in native
-        result = selectImpl(readFDs, writeFDs, countRead, countWrite, flags,
-                timeout);
+        assert validateFDs(readFDs, writeFDs, numReadable, numWritable) : "Invalid file descriptor arrays"; //$NON-NLS-1$
 
-        if (0 <= result) {
-            return flags;
+        // handle timeout in native
+        int result = selectImpl(readFDs, writeFDs, numReadable, numWritable, flags, timeout);
+        if (result >= 0) {
+            return true;
         }
-        if (ERRORCODE_SOCKET_TIMEOUT == result ||
-            ERRORCODE_SOCKET_INTERRUPTED == result) {
-            return new int[0];
+        if (result == ERRORCODE_SOCKET_TIMEOUT ||
+                result == ERRORCODE_SOCKET_INTERRUPTED) {
+            return false;
         }
         throw new SocketException();
     }
@@ -497,6 +475,22 @@
         return true;
     }
 
+    private boolean validateFDs(FileDescriptor[] readFDs,
+            FileDescriptor[] writeFDs, int countRead, int countWrite) {
+        for (int i = 0; i < countRead; ++i) {
+            // Also checks fd not null
+            if (!readFDs[i].valid()) {
+                return false;
+            }
+        }
+        for (int i = 0; i < countWrite; ++i) {
+            if (!writeFDs[i].valid()) {
+                return false;
+            }
+        }
+        return true;
+    }
+
     /**
      * Write bytes from a byte array to a socket.
      * 

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/platform/RuntimeMemorySpy.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/platform/RuntimeMemorySpy.java?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/platform/RuntimeMemorySpy.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/platform/RuntimeMemorySpy.java Thu Nov 26 11:12:49 2009
@@ -20,18 +20,18 @@
 
 final class RuntimeMemorySpy extends AbstractMemorySpy {
 
-	public RuntimeMemorySpy() {
-		super();
-	}
+    public RuntimeMemorySpy() {
+        super();
+    }
 
-	public void alloc(PlatformAddress address) {
-		// Pay a tax on the allocation to see if there are any frees pending.
-		Reference ref = notifyQueue.poll(); // non-blocking check
-		while (ref != null) {
-			orphanedMemory(ref);
-			ref = notifyQueue.poll();
-		}
+    public void alloc(PlatformAddress address) {
+        // Pay a tax on the allocation to see if there are any frees pending.
+        Reference ref = notifyQueue.poll(); // non-blocking check
+        while (ref != null) {
+            orphanedMemory(ref);
+            ref = notifyQueue.poll();
+        }
 
         super.alloc(address);
-	}
+    }
 }

Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/hyzip/shared/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Nov 26 11:12:49 2009
@@ -0,0 +1 @@
+*.obj

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/hyzip/shared/zipcache.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/hyzip/shared/zipcache.c?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/hyzip/shared/zipcache.c (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/hyzip/shared/zipcache.c Thu Nov 26 11:12:49 2009
@@ -469,7 +469,7 @@
 
   if (zce->chunkActiveDir == dirEntry)
     {
-      if (entry = (HyZipFileEntry *) zipCache_reserveEntry (zce, chunk, sizeof (*entry), nameSize + 1))
+      if ((entry = (HyZipFileEntry *) zipCache_reserveEntry (zce, chunk, sizeof (*entry), nameSize + 1)))
         {
           /* add to end of existing entry */
           zce->chunkActiveDir->fileList->entryCount++;

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/hyzip/shared/zipsup.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/hyzip/shared/zipsup.c?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/hyzip/shared/zipsup.c (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/hyzip/shared/zipsup.c Thu Nov 26 11:12:49 2009
@@ -351,13 +351,13 @@
                 {
                   /* Found it.  Read the data from the end-of-central-dir record. */
                   current = buffer + i + 4;
-                  ZIP_NEXT_U16 (endEntry->diskNumber, current);
-                  ZIP_NEXT_U16 (endEntry->dirStartDisk, current);
-                  ZIP_NEXT_U16 (endEntry->thisDiskEntries, current);
-                  ZIP_NEXT_U16 (endEntry->totalEntries, current);
-                  ZIP_NEXT_U32 (endEntry->dirSize, current);
-                  ZIP_NEXT_U32 (endEntry->dirOffset, current);
-                  ZIP_NEXT_U16 (endEntry->commentLength, current);
+                  (void) ZIP_NEXT_U16 (endEntry->diskNumber, current);
+                  (void) ZIP_NEXT_U16 (endEntry->dirStartDisk, current);
+                  (void) ZIP_NEXT_U16 (endEntry->thisDiskEntries, current);
+                  (void) ZIP_NEXT_U16 (endEntry->totalEntries, current);
+                  (void) ZIP_NEXT_U32 (endEntry->dirSize, current);
+                  (void) ZIP_NEXT_U32 (endEntry->dirOffset, current);
+                  (void) ZIP_NEXT_U16 (endEntry->commentLength, current);
 
                   /* Quick test to ensure that the header isn't invalid. 
                      Current dataSize is the number of bytes of data scanned, up to the ^H in the stream. */
@@ -499,9 +499,9 @@
                     }
 
                   /* Read the data from the descriptor. */
-                  ZIP_NEXT_U32 (zipEntry->crc32, current);
-                  ZIP_NEXT_U32 (zipEntry->compressedSize, current);
-                  ZIP_NEXT_U32 (zipEntry->uncompressedSize, current);
+                  (void) ZIP_NEXT_U32 (zipEntry->crc32, current);
+                  (void) ZIP_NEXT_U32 (zipEntry->compressedSize, current);
+                  (void) ZIP_NEXT_U32 (zipEntry->uncompressedSize, current);
 
                   /* Quick test to ensure that the header isn't invalid. 
                      Current dataSize is the number of bytes of data scanned, up to the ^H in the stream. */
@@ -642,7 +642,7 @@
             zipFile->pointer + (current - (buffer + bufferedSize));
 
           sig = 0;
-          ZIP_NEXT_U32 (sig, current);
+          (void) ZIP_NEXT_U32 (sig, current);
           if (sig == ZIP_CentralEnd)
             {
               /* We're done here. */
@@ -657,22 +657,22 @@
             }
 
           /* Read ZIP_CentralHeader entry */
-          ZIP_NEXT_U16 (entry.versionCreated, current);
-          ZIP_NEXT_U16 (entry.versionNeeded, current);
-          ZIP_NEXT_U16 (entry.flags, current);
-          ZIP_NEXT_U16 (entry.compressionMethod, current);
-          ZIP_NEXT_U16 (entry.lastModTime, current);
-          ZIP_NEXT_U16 (entry.lastModDate, current);
-          ZIP_NEXT_U32 (entry.crc32, current);
-          ZIP_NEXT_U32 (entry.compressedSize, current);
-          ZIP_NEXT_U32 (entry.uncompressedSize, current);
-          ZIP_NEXT_U16 (entry.filenameLength, current);
-          ZIP_NEXT_U16 (entry.extraFieldLength, current);
-          ZIP_NEXT_U16 (entry.fileCommentLength, current);
+          (void) ZIP_NEXT_U16 (entry.versionCreated, current);
+          (void) ZIP_NEXT_U16 (entry.versionNeeded, current);
+          (void) ZIP_NEXT_U16 (entry.flags, current);
+          (void) ZIP_NEXT_U16 (entry.compressionMethod, current);
+          (void) ZIP_NEXT_U16 (entry.lastModTime, current);
+          (void) ZIP_NEXT_U16 (entry.lastModDate, current);
+          (void) ZIP_NEXT_U32 (entry.crc32, current);
+          (void) ZIP_NEXT_U32 (entry.compressedSize, current);
+          (void) ZIP_NEXT_U32 (entry.uncompressedSize, current);
+          (void) ZIP_NEXT_U16 (entry.filenameLength, current);
+          (void) ZIP_NEXT_U16 (entry.extraFieldLength, current);
+          (void) ZIP_NEXT_U16 (entry.fileCommentLength, current);
           current += sizeof (U_16);     /* skip disk number field */
-          ZIP_NEXT_U16 (entry.internalAttributes, current);
+          (void) ZIP_NEXT_U16 (entry.internalAttributes, current);
           current += sizeof (U_32);     /* skip external attributes field */
-          ZIP_NEXT_U32 (localHeaderOffset, current);
+          (void) ZIP_NEXT_U32 (localHeaderOffset, current);
 
           /* Increase filename buffer size if necessary. */
           if (filenameSize < entry.filenameLength + 1)
@@ -871,7 +871,7 @@
     }
   zipFile->pointer += result;
   readLength = result;          /* If it's not enough, we'll catch that later */
-  ZIP_NEXT_U32 (sig, current);
+  (void) ZIP_NEXT_U32 (sig, current);
 
   if (enumerationPointer)
     {
@@ -930,23 +930,23 @@
     {
       current += 2;             /* skip versionCreated field */
     }
-  ZIP_NEXT_U16 (zipEntry->versionNeeded, current);
-  ZIP_NEXT_U16 (zipEntry->flags, current);
-  ZIP_NEXT_U16 (zipEntry->compressionMethod, current);
-  ZIP_NEXT_U16 (zipEntry->lastModTime, current);
-  ZIP_NEXT_U16 (zipEntry->lastModDate, current);
-  ZIP_NEXT_U32 (zipEntry->crc32, current);
-  ZIP_NEXT_U32 (zipEntry->compressedSize, current);
-  ZIP_NEXT_U32 (zipEntry->uncompressedSize, current);
-  ZIP_NEXT_U16 (zipEntry->filenameLength, current);
-  ZIP_NEXT_U16 (zipEntry->extraFieldLength, current);
+  (void) ZIP_NEXT_U16 (zipEntry->versionNeeded, current);
+  (void) ZIP_NEXT_U16 (zipEntry->flags, current);
+  (void) ZIP_NEXT_U16 (zipEntry->compressionMethod, current);
+  (void) ZIP_NEXT_U16 (zipEntry->lastModTime, current);
+  (void) ZIP_NEXT_U16 (zipEntry->lastModDate, current);
+  (void) ZIP_NEXT_U32 (zipEntry->crc32, current);
+  (void) ZIP_NEXT_U32 (zipEntry->compressedSize, current);
+  (void) ZIP_NEXT_U32 (zipEntry->uncompressedSize, current);
+  (void) ZIP_NEXT_U16 (zipEntry->filenameLength, current);
+  (void) ZIP_NEXT_U16 (zipEntry->extraFieldLength, current);
   zipEntry->fileCommentLength = 0;
 
   if (sig == ZIP_CentralHeader)
     {
-      ZIP_NEXT_U16 (zipEntry->fileCommentLength, current);
+      (void) ZIP_NEXT_U16 (zipEntry->fileCommentLength, current);
       current += 8;             /* skip disk number start + internal attrs + external attrs */
-      ZIP_NEXT_U32 (localEntryPointer, current);
+      (void) ZIP_NEXT_U32 (localEntryPointer, current);
     }
 
   if (filename)
@@ -1043,7 +1043,7 @@
         {
           if (hyfile_read (zipFile->fd, buf, 2) == 2)
             {
-              ZIP_NEXT_U16 (lost, buf2);
+              (void) ZIP_NEXT_U16 (lost, buf2);
               zipEntry->dataPointer = zipEntry->extraFieldPointer + lost;
               zipFile->pointer = localEntryPointer + 30;
             }

Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/hyzip/windows/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Nov 26 11:12:49 2009
@@ -0,0 +1 @@
+*.pdb

Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/fdlibm.h
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Nov 26 11:12:49 2009
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/fdlibm.h:803062-824035
+/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/fdlibm.h:803062-884286

Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/gp.h
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Nov 26 11:12:49 2009
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/gp.h:803062-824035
+/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/gp.h:803062-884286

Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/hymagic.h
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Nov 26 11:12:49 2009
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/hymagic.h:803062-824035
+/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/hymagic.h:803062-884286

Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/hysocket.h
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Nov 26 11:12:49 2009
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/hysocket.h:803062-824035
+/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/hysocket.h:803062-884286

Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/hyvmls.h
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Nov 26 11:12:49 2009
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/hyvmls.h:803062-824035
+/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/hyvmls.h:803062-884286

Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/jni.h
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Nov 26 11:12:49 2009
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/jni.h:803062-824035
+/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/jni.h:803062-884286

Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/jni_types.h
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Nov 26 11:12:49 2009
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/jni_types.h:803062-824035
+/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/jni_types.h:803062-884286

Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/jvmpi.h
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Nov 26 11:12:49 2009
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/jvmpi.h:803062-824035
+/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/jvmpi.h:803062-884286

Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/jvmri.h
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Nov 26 11:12:49 2009
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/jvmri.h:803062-824035
+/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/jvmri.h:803062-884286

Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/jvmti.h
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Nov 26 11:12:49 2009
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/jvmti.h:803062-824035
+/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/jvmti.h:803062-884286

Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/jvmti_types.h
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Nov 26 11:12:49 2009
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/jvmti_types.h:803062-824035
+/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/jvmti_types.h:803062-884286

Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/vmi.h
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Nov 26 11:12:49 2009
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/vmi.h:803062-824035
+/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/vmi.h:803062-884286

Propchange: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/vmizip.h
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Nov 26 11:12:49 2009
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/vmizip.h:803062-824035
+/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/vmizip.h:803062-884286

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/launcher/unix/main_hlp.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/launcher/unix/main_hlp.c?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/launcher/unix/main_hlp.c (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/launcher/unix/main_hlp.c Thu Nov 26 11:12:49 2009
@@ -345,9 +345,9 @@
         {                       /* empty path entry */
           continue;
         }
-      if (sdir = opendir (temp))
+      if ((sdir = opendir (temp)))
         {
-          while (dirEntry = readdir (sdir))
+          while ((dirEntry = readdir (sdir)))
             {
               if (!strcmp (dirEntry->d_name, filename))
                 {

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/shared/OSNetworkSystem.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/shared/OSNetworkSystem.c?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/shared/OSNetworkSystem.c (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/shared/OSNetworkSystem.c Thu Nov 26 11:12:49 2009
@@ -588,10 +588,27 @@
                                     HY_PORT_SOCKET_STEP_START, &context);
       break;
     case SOCKET_CONNECT_STEP_CHECK:
-
-      result =
-        hysock_connect_with_timeout(socketP, &sockaddrP, timeout,
+      if (timeout == -1) {
+            /* Blocking connect, so loop for a reasonable amount of time, then
+             * throw a ConnectException if we still fail to connect. This matches
+             * the behaviour of the RI with a similar timeout.
+             */
+            int i = 0;
+            for (; i<1000; i++) {
+                result = hysock_connect_with_timeout(socketP, &sockaddrP, 100,
                                     HY_PORT_SOCKET_STEP_CHECK, &context);
+                if (0 == result) {
+                    break;
+                }
+            }
+            if (0 != result) {
+                throwJavaNetConnectException(env, result);
+                return result;
+            }
+        } else {
+            result = hysock_connect_with_timeout(socketP, &sockaddrP, timeout,
+                                    HY_PORT_SOCKET_STEP_CHECK, &context);
+        }
       break;
     }
 

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/shared/file.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/shared/file.c?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/shared/file.c (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/shared/file.c Thu Nov 26 11:12:49 2009
@@ -94,7 +94,7 @@
   if (length >= 1 && pathCopy[length - 1] != '\\'
       && pathCopy[length - 1] != '/')
     {
-      pathCopy[length] = jclSeparator;
+      pathCopy[length] = DIR_SEPARATOR;
       length++;
     }
   pathCopy[length] = '\0';

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/windows/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/windows/makefile?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/windows/makefile (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/windows/makefile Thu Nov 26 11:12:49 2009
@@ -52,6 +52,5 @@
   $(LIBPATH)hyfdlibm$(HY_LINKLIB_SUFFIX) $(LIBPATH)vmi$(HY_LINKLIB_SUFFIX)
 
 DLLBASE=0x13200000
-COMMENT=/comment:"LUNI component native code. (c) Copyright 1991, 2009 The Apache Software Foundation or its licensors, as applicable."
 
 !include <$(HY_HDK)\build\make\rules.mak>

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/BufferedOutputStreamTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/BufferedOutputStreamTest.java?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/BufferedOutputStreamTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/BufferedOutputStreamTest.java Thu Nov 26 11:12:49 2009
@@ -328,9 +328,9 @@
 
         try {
             bos.write(byteArray, -1, -1);
-            fail("should throw ArrayIndexOutOfBoundsException");
-        } catch (ArrayIndexOutOfBoundsException e) {
-            // expected
+            fail();
+        } catch (Exception e) {
+            // expected IOException. RI throws IndexOutOfBoundsException
         }
     }
 
@@ -663,11 +663,6 @@
         buffos.flush();
 
         buffos.close();
-
-        buffos.write(Integer.MIN_VALUE);
-        buffos.write(Integer.MAX_VALUE);
-        buffos.write(buffer, 0, 10);
-        buffos.flush();
     }
 
     public void test_write_Scenario1() throws IOException {
@@ -751,8 +746,6 @@
             assertEquals(buffer2[i], byteArrayis.read());
         }
 
-        buffos.close();
-
         byte[] buffer3 = new byte[] { 'e', 'f', 'g', 'h', 'i' };
         buffos.write(buffer3, 0, 5);
         byteArrayis = new ByteArrayInputStream(byteArrayos.toByteArray());
@@ -778,6 +771,8 @@
         byteArrayis = new ByteArrayInputStream(byteArrayos.toByteArray());
         assertEquals("Bytes not written after flush", 21, byteArrayis
                 .available());
+
+        buffos.close();
     }
 
     public void test_write_Scenario3() throws IOException {

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/BufferedReaderTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/BufferedReaderTest.java?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/BufferedReaderTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/BufferedReaderTest.java Thu Nov 26 11:12:49 2009
@@ -528,8 +528,8 @@
     public void test_reset_IOException() throws Exception {
         int[] expected = new int[] { '1', '2', '3', '4', '5', '6', '7', '8',
                 '9', '0', -1 };
-        br = new BufferedReader(new Support_StringReader("1234567890"));
-        br.mark(10);
+        br = new BufferedReader(new Support_StringReader("1234567890"), 9);
+        br.mark(9);
         for (int i = 0; i < 11; i++) {
             assertEquals(expected[i], br.read());
         }

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/LineNumberReaderTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/LineNumberReaderTest.java?rev=884518&r1=884517&r2=884518&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/LineNumberReaderTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/LineNumberReaderTest.java Thu Nov 26 11:12:49 2009
@@ -21,6 +21,7 @@
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.LineNumberReader;
+import java.io.Reader;
 import java.io.StringReader;
 
 import junit.framework.TestCase;
@@ -143,6 +144,54 @@
         assertEquals("Failed to reset reader", "0", line);
     }
 
+    public void testReadLineSourceThrows() throws IOException {
+        lnr = new LineNumberReader(new Reader() {
+            private StringReader delegate = new StringReader("hello\nworld");
+            private int calls = 0;
+            @Override public void close() throws IOException {}
+            @Override public int read(char[] buf, int offset, int len) throws IOException {
+                if (calls++ < 2) {
+                    throw new IOException();
+                } else {
+                    return delegate.read(buf, offset, len);
+                }
+            }
+        });
+
+        assertEquals(0, lnr.getLineNumber());
+        try {
+            lnr.readLine();
+            fail();
+        } catch (IOException expected) {
+        }
+
+        assertEquals(0, lnr.getLineNumber());
+        try {
+            lnr.readLine();
+            fail();
+        } catch (IOException expected) {
+        }
+
+        assertEquals(0, lnr.getLineNumber());
+        assertEquals("hello", lnr.readLine());
+        assertEquals(1, lnr.getLineNumber());
+        assertEquals("world", lnr.readLine());
+        assertEquals(2, lnr.getLineNumber());
+    }
+
+    public void testGetLineNumberAfterEnd() throws IOException {
+        lnr = new LineNumberReader(new StringReader("hello\nworld"));
+        assertEquals(0, lnr.getLineNumber());
+        assertEquals("hello", lnr.readLine());
+        assertEquals(1, lnr.getLineNumber());
+        assertEquals("world", lnr.readLine());
+        assertEquals(2, lnr.getLineNumber());
+        assertEquals(null, lnr.readLine());
+        assertEquals(2, lnr.getLineNumber());
+        assertEquals(null, lnr.readLine());
+        assertEquals(2, lnr.getLineNumber());
+    }
+
     /**
      * @tests java.io.LineNumberReader#setLineNumber(int)
      */



Mime
View raw message