This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH to use ByteBufferHelper more


This is a standalone and hopefully uncontroversial
subset of my patch.  It primarily fixes the code to
use the correct byte-order and defers all the
getChar/putLong etc methods to use ByteBufferHelper.

There is also an optimization of compact().

Tested on the 3.4 branch by running the testsuite.
--
	--Per Bothner
per@bothner.com   http://per.bothner.com/


2004-02-06  Per Bothner  <per@bothner.com>

	* java/nio/ByteBuffer.java (shiftDown):  New helper method.
	* java/nio/natDirectByteBufferImpl.cc (shiftDown):  New implementation.
	* java/nio/ByteBufferImpl.java (compact):  Use new shiftDown method.
	* sava/nio/ByteBufferHelper.java:  Remove redundant 'final' specifiers.
	Pass ByteOrder parameter to most methods, since the underlying
	ByteBuffer's order isn't always what we should use.
	* java/nio/ByteBufferImpl.java:  Pass byte-order various places.
	* java/nio/DirectByteBufferImpl.java:  Likewise.
	Use ByteBufferHelper methods.
	* java/nio/MappedByteBufferImpl.java:  Likewise.
	(compact):  Use shiftDown.
	* java/nio/CharViewBufferImpl.java (<init>):  Pass byte-order.
	(get, put):  Use ByteBufferHelper.
	(compact):  Use new shiftDown method.
	(duplicate(boolean)):  New helper method.
	(duplicate, asReadOnlyBuffer):  Use it.
	(order):  Return endian field.
	* java/nio/DoubleViewBufferImpl.java:  Likewise.
	* java/nio/FloatViewBufferImpl.java:  Likewise.
	* java/nio/IntViewBufferImpl.java:  Likewise.
	* java/nio/LongViewBufferImpl.java:  Likewise.
	* java/nio/ShortViewBufferImpl.java:  Likewise.
	* java/nio/CharViewBufferImpl.java (subsequence):  Redundant test.
	* java/nio/DirectByteBufferImpl.java (shiftDown):  New native method.
	(compact):  Re-implement using shiftDown.

Index: java/nio/ByteBuffer.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/ByteBuffer.java,v
retrieving revision 1.14
diff -u -p -r1.14 ByteBuffer.java
--- java/nio/ByteBuffer.java	11 Nov 2003 11:56:58 -0000	1.14
+++ java/nio/ByteBuffer.java	6 Feb 2004 17:45:50 -0000
@@ -1,5 +1,5 @@
 /* ByteBuffer.java -- 
-   Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -382,8 +382,14 @@ public abstract class ByteBuffer extends
    */
   public abstract ByteBuffer compact ();
 
+  void shiftDown (int dst_offset, int src_offset, int count)
+  {
+    for (int i = 0; i < count; i++)
+      put(dst_offset + i, get(src_offset + i));
+  }
+
   /**
-   * Tells wether or not this buffer is direct.
+   * Tells whether or not this buffer is direct.
    */
   public abstract boolean isDirect ();
 
Index: java/nio/ByteBufferHelper.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/ByteBufferHelper.java,v
retrieving revision 1.3
diff -u -p -r1.3 ByteBufferHelper.java
--- java/nio/ByteBufferHelper.java	2 Oct 2003 15:02:32 -0000	1.3
+++ java/nio/ByteBufferHelper.java	6 Feb 2004 17:45:50 -0000
@@ -1,5 +1,5 @@
 /* ByteBufferImpl.java -- 
-   Copyright (C) 2003 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -42,58 +42,58 @@ package java.nio;
  */
 final class ByteBufferHelper
 {
-  private static final void checkRemainingForRead (ByteBuffer buffer, int bytes)
+  private static void checkRemainingForRead (ByteBuffer buffer, int bytes)
   {
     if (buffer.remaining() < bytes)
       throw new BufferUnderflowException();
   }
   
-  private static final void checkRemainingForWrite (ByteBuffer buffer, int bytes)
+  private static void checkRemainingForWrite (ByteBuffer buffer, int bytes)
   {
     if (buffer.remaining() < bytes)
       throw new BufferOverflowException();
   }
 
-  private static final void checkAvailableForRead (ByteBuffer buffer,
-                                                   int index, int bytes)
+  private static void checkAvailableForRead (ByteBuffer buffer,
+					     int index, int bytes)
   {
     if (buffer.limit() < (index + bytes))
       throw new BufferUnderflowException();
   }
   
-  private static final void checkAvailableForWrite (ByteBuffer buffer,
-                                                    int index, int bytes)
+  private static void checkAvailableForWrite (ByteBuffer buffer,
+					      int index, int bytes)
   {
     if (buffer.limit() < (index + bytes))
       throw new BufferOverflowException();
   }
   
-  public static final char getChar (ByteBuffer buffer)
+  public static char getChar (ByteBuffer buffer, ByteOrder order)
   {
-    return (char) getShort (buffer);
+    return (char) getShort (buffer, order);
   }
   
-  public static final ByteBuffer putChar (ByteBuffer buffer, char value)
+  public static void putChar (ByteBuffer buffer, char value, ByteOrder order)
   {
-    return putShort (buffer, (short) value);
+    putShort (buffer, (short) value, order);
   }
   
-  public static final char getChar (ByteBuffer buffer, int index)
+  public static char getChar (ByteBuffer buffer, int index, ByteOrder order)
   {
-    return (char) getShort (buffer, index);
+    return (char) getShort (buffer, index, order);
   }
   
-  public static final ByteBuffer putChar (ByteBuffer buffer, int index,
-                                          char value)
+  public static void putChar (ByteBuffer buffer, int index,
+			      char value, ByteOrder order)
   {
-    return putShort (buffer, index, (short) value);
+    putShort (buffer, index, (short) value, order);
   }
 
-  public static final short getShort (ByteBuffer buffer)
+  public static short getShort (ByteBuffer buffer, ByteOrder order)
   {
     checkRemainingForRead (buffer, 2);
 
-    if (buffer.order() == ByteOrder.LITTLE_ENDIAN)
+    if (order == ByteOrder.LITTLE_ENDIAN)
       {
         return (short) ((buffer.get() & 0xff)
                         + (buffer.get() << 8));
@@ -103,11 +103,11 @@ final class ByteBufferHelper
                     + (buffer.get() & 0xff));
   }
   
-  public static final ByteBuffer putShort (ByteBuffer buffer, short value)
+  public static void putShort (ByteBuffer buffer, short value, ByteOrder order)
   {
     checkRemainingForWrite (buffer, 2);
 
-    if (buffer.order() == ByteOrder.LITTLE_ENDIAN)
+    if (order == ByteOrder.LITTLE_ENDIAN)
       {
         buffer.put ((byte) value);
         buffer.put ((byte) (value >> 8));
@@ -117,15 +117,14 @@ final class ByteBufferHelper
         buffer.put ((byte) (value >> 8));
         buffer.put ((byte) value);
       }
-
-    return buffer;
   }
   
-  public static final short getShort (ByteBuffer buffer, int index)
+  public static short getShort (ByteBuffer buffer,
+				      int index, ByteOrder order)
   {
     checkAvailableForRead (buffer, index, 2);
 
-    if (buffer.order() == ByteOrder.LITTLE_ENDIAN)
+    if (order == ByteOrder.LITTLE_ENDIAN)
       {
         return (short) ((buffer.get (index) & 0xff)
                         + (buffer.get (++index) << 8));
@@ -135,12 +134,12 @@ final class ByteBufferHelper
                     + (buffer.get (++index) & 0xff));
   }
   
-  public static final ByteBuffer putShort (ByteBuffer buffer, int index,
-                                           short value)
+  public static void putShort (ByteBuffer buffer, int index,
+			       short value, ByteOrder order)
   {
     checkAvailableForWrite (buffer, index, 2);
 
-    if (buffer.order() == ByteOrder.LITTLE_ENDIAN)
+    if (order == ByteOrder.LITTLE_ENDIAN)
       {
         buffer.put (index, (byte) value);
         buffer.put (++index, (byte) (value >> 8));
@@ -150,15 +149,13 @@ final class ByteBufferHelper
         buffer.put (index, (byte) (value >> 8));
         buffer.put (++index, (byte) value);
       }
-    
-    return buffer;
   }
 
-  public static final int getInt (ByteBuffer buffer)
+  public static int getInt (ByteBuffer buffer, ByteOrder order)
   {
     checkRemainingForRead (buffer, 4);
 
-    if (buffer.order() == ByteOrder.LITTLE_ENDIAN)
+    if (order == ByteOrder.LITTLE_ENDIAN)
       {
         return ((buffer.get() & 0xff)
                 + ((buffer.get() & 0xff) << 8)
@@ -172,11 +169,11 @@ final class ByteBufferHelper
                   + (buffer.get() & 0xff));
   }
   
-  public static final ByteBuffer putInt (ByteBuffer buffer, int value)
+  public static void putInt (ByteBuffer buffer, int value, ByteOrder order)
   {
     checkRemainingForWrite (buffer, 4);
 
-    if (buffer.order() == ByteOrder.LITTLE_ENDIAN)
+    if (order == ByteOrder.LITTLE_ENDIAN)
       {
         buffer.put ((byte) value);
         buffer.put ((byte) (value >> 8));
@@ -190,15 +187,13 @@ final class ByteBufferHelper
         buffer.put ((byte) (value >> 8));
         buffer.put ((byte) value);
       }
-    
-    return buffer;
   }
   
-  public static final int getInt (ByteBuffer buffer, int index)
+  public static int getInt (ByteBuffer buffer, int index, ByteOrder order)
   {
     checkAvailableForRead (buffer, index, 4);
 
-    if (buffer.order() == ByteOrder.LITTLE_ENDIAN)
+    if (order == ByteOrder.LITTLE_ENDIAN)
       {
         return ((buffer.get (index) & 0xff)
                 + ((buffer.get (++index) & 0xff) << 8)
@@ -212,12 +207,12 @@ final class ByteBufferHelper
             + (buffer.get (++index) & 0xff));
   }
   
-  public static final ByteBuffer putInt (ByteBuffer buffer, int index,
-                                         int value)
+  public static void putInt (ByteBuffer buffer, int index,
+				   int value, ByteOrder order)
   {
     checkAvailableForWrite (buffer, index, 4);
 
-    if (buffer.order() == ByteOrder.LITTLE_ENDIAN)
+    if (order == ByteOrder.LITTLE_ENDIAN)
       {
         buffer.put (index, (byte) value);
         buffer.put (++index, (byte) (value >> 8));
@@ -231,15 +226,13 @@ final class ByteBufferHelper
         buffer.put (++index, (byte) (value >> 8));
         buffer.put (++index, (byte) value);
       }
-  
-    return buffer;
   }
 
-  public static final long getLong (ByteBuffer buffer)
+  public static long getLong (ByteBuffer buffer, ByteOrder order)
   {
     checkRemainingForRead (buffer, 8);
 
-    if (buffer.order() == ByteOrder.LITTLE_ENDIAN)
+    if (order == ByteOrder.LITTLE_ENDIAN)
       {
         return ((buffer.get() & 0xff)
                 + (((buffer.get() & 0xff)) << 8)
@@ -261,11 +254,11 @@ final class ByteBufferHelper
             + (buffer.get() & 0xff));
   }
   
-  public static final ByteBuffer putLong (ByteBuffer buffer, long value)
+  public static void putLong (ByteBuffer buffer, long value, ByteOrder order)
   {
     checkRemainingForWrite (buffer, 8);
 
-    if (buffer.order() == ByteOrder.LITTLE_ENDIAN)
+    if (order == ByteOrder.LITTLE_ENDIAN)
       {
         buffer.put ((byte) value);
         buffer.put ((byte) (value >> 8));
@@ -287,15 +280,13 @@ final class ByteBufferHelper
         buffer.put ((byte) (value >> 8));
         buffer.put ((byte) value);
       }
-    
-    return buffer;
   }
   
-  public static final long getLong (ByteBuffer buffer, int index)
+  public static long getLong (ByteBuffer buffer, int index, ByteOrder order)
   {
     checkAvailableForRead (buffer, index, 8);
 
-    if (buffer.order() == ByteOrder.LITTLE_ENDIAN)
+    if (order == ByteOrder.LITTLE_ENDIAN)
       {
         return ((buffer.get (index) & 0xff)
                 + ((buffer.get (++index) & 0xff) << 8)
@@ -317,12 +308,12 @@ final class ByteBufferHelper
             + (buffer.get (++index) & 0xff));
   }
   
-  public static final ByteBuffer putLong (ByteBuffer buffer, int index,
-                                          long value)
+  public static void putLong (ByteBuffer buffer, int index,
+				    long value, ByteOrder order)
   {
     checkAvailableForWrite (buffer, index, 8);
 
-    if (buffer.order() == ByteOrder.LITTLE_ENDIAN)
+    if (order == ByteOrder.LITTLE_ENDIAN)
       {
         buffer.put (index, (byte) value);
         buffer.put (++index, (byte) (value >> 8));
@@ -344,50 +335,47 @@ final class ByteBufferHelper
         buffer.put (++index, (byte) (value >> 8));
         buffer.put (++index, (byte) value);
       }
-    
-    return buffer;
   }
 
-  public static final float getFloat (ByteBuffer buffer)
+  public static float getFloat (ByteBuffer buffer, ByteOrder order)
   {
-    return Float.intBitsToFloat (getInt (buffer));
+    return Float.intBitsToFloat (getInt (buffer, order));
   }
   
-  public static final ByteBuffer putFloat (ByteBuffer buffer, float value)
+  public static void putFloat (ByteBuffer buffer, float value, ByteOrder order)
   {
-    return putInt (buffer, Float.floatToRawIntBits (value));
+    putInt (buffer, Float.floatToRawIntBits (value), order);
   }
   
-  public static final float getFloat (ByteBuffer buffer, int index)
+  public static float getFloat (ByteBuffer buffer, int index, ByteOrder order)
   {
-    return Float.intBitsToFloat (getInt (buffer, index));
+    return Float.intBitsToFloat (getInt (buffer, index, order));
   }
 
-  public static final ByteBuffer putFloat (ByteBuffer buffer, int index,
-                                           float value)
+  public static void putFloat (ByteBuffer buffer, int index,
+				     float value, ByteOrder order)
   {
-    return putInt (buffer, index, Float.floatToRawIntBits (value));
+    putInt (buffer, index, Float.floatToRawIntBits (value), order);
   }
 
-  public static final double getDouble (ByteBuffer buffer)
+  public static double getDouble (ByteBuffer buffer, ByteOrder order)
   {
-    return Double.longBitsToDouble (getLong (buffer));
+    return Double.longBitsToDouble (getLong (buffer, order));
   }
 
-  public static final ByteBuffer putDouble (ByteBuffer buffer, double value)
+  public static void putDouble (ByteBuffer buffer, double value, ByteOrder order)
   {
-    return putLong (buffer, Double.doubleToLongBits (value));
+    putLong (buffer, Double.doubleToLongBits (value), order);
   }
   
-  public static final double getDouble (ByteBuffer buffer, int index)
+  public static double getDouble (ByteBuffer buffer, int index, ByteOrder order)
   {
-    return Double.longBitsToDouble (getLong (buffer, index));
+    return Double.longBitsToDouble (getLong (buffer, index, order));
   }
   
-  public static final ByteBuffer putDouble (ByteBuffer buffer, int index,
-                                            double value)
+  public static void putDouble (ByteBuffer buffer, int index,
+				double value, ByteOrder order)
   {
-    return putLong (buffer, index, Double.doubleToLongBits (value));
+    putLong (buffer, index, Double.doubleToLongBits (value), order);
   }
-
 } // ByteBufferHelper
Index: java/nio/ByteBufferImpl.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/ByteBufferImpl.java,v
retrieving revision 1.4
diff -u -p -r1.4 ByteBufferImpl.java
--- java/nio/ByteBufferImpl.java	25 Sep 2003 06:43:52 -0000	1.4
+++ java/nio/ByteBufferImpl.java	6 Feb 2004 17:45:50 -0000
@@ -1,5 +1,5 @@
 /* ByteBufferImpl.java -- 
-   Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -58,32 +58,32 @@ final class ByteBufferImpl extends ByteB
   
   public CharBuffer asCharBuffer ()
   {
-    return new CharViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly ());
+    return new CharViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly (), order());
   }
 
   public ShortBuffer asShortBuffer ()
   {
-    return new ShortViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly ());
+    return new ShortViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly (), order());
   }
 
   public IntBuffer asIntBuffer ()
   {
-    return new IntViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly ());
+    return new IntViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly (), order());
   }
 
   public LongBuffer asLongBuffer ()
   {
-    return new LongViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly ());
+    return new LongViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly (), order());
   }
 
   public FloatBuffer asFloatBuffer ()
   {
-    return new FloatViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly ());
+    return new FloatViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly (), order());
   }
 
   public DoubleBuffer asDoubleBuffer ()
   {
-    return new DoubleViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly ());
+    return new DoubleViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly (), order());
   }
 
   public boolean isReadOnly ()
@@ -108,15 +108,14 @@ final class ByteBufferImpl extends ByteB
   
   public ByteBuffer compact ()
   {
-    int copied = 0;
-    
-    while (remaining () > 0)
+    int pos = position();
+    if (pos > 0)
       {
-	put (copied, get ());
-	copied++;
+	int count = remaining();
+	shiftDown(0, pos, count);
+	position(count);
+	limit(capacity());
       }
-
-    position (copied);
     return this;
   }
   
@@ -182,121 +181,133 @@ final class ByteBufferImpl extends ByteB
   
   final public char getChar ()
   {
-    return ByteBufferHelper.getChar (this);
+    return ByteBufferHelper.getChar(this, order());
   }
   
   final public ByteBuffer putChar (char value)
   {
-    return ByteBufferHelper.putChar (this, value);
+    ByteBufferHelper.putChar(this, value, order());
+    return this;
   }
   
   final public char getChar (int index)
   {
-    return ByteBufferHelper.getChar (this, index);
+    return ByteBufferHelper.getChar(this, index, order());
   }
   
   final public ByteBuffer putChar (int index, char value)
   {
-    return ByteBufferHelper.putChar (this, index, value);
+    ByteBufferHelper.putChar(this, index, value, order());
+    return this;
   }
 
   final public short getShort ()
   {
-    return ByteBufferHelper.getShort (this);
+    return ByteBufferHelper.getShort(this, order());
   }
   
   final public ByteBuffer putShort (short value)
   {
-    return ByteBufferHelper.putShort (this, value);
+    ByteBufferHelper.putShort(this, value, order());
+    return this;
   }
   
   final public short getShort (int index)
   {
-    return ByteBufferHelper.getShort (this, index);
+    return ByteBufferHelper.getShort(this, index, order());
   }
   
   final public ByteBuffer putShort (int index, short value)
   {
-    return ByteBufferHelper.putShort (this, index, value);
+    ByteBufferHelper.putShort(this, index, value, order());
+    return this;
   }
 
   final public int getInt ()
   {
-    return ByteBufferHelper.getInt (this);
+    return ByteBufferHelper.getInt(this, order());
   }
   
   final public ByteBuffer putInt (int value)
   {
-    return ByteBufferHelper.putInt (this, value);
+    ByteBufferHelper.putInt(this, value, order());
+    return this;
   }
   
   final public int getInt (int index)
   {
-    return ByteBufferHelper.getInt (this, index);
+    return ByteBufferHelper.getInt(this, index, order());
   }
   
   final public ByteBuffer putInt (int index, int value)
   {
-    return ByteBufferHelper.putInt (this, index, value);
+    ByteBufferHelper.putInt(this, index, value, order());
+    return this;
   }
 
   final public long getLong ()
   {
-    return ByteBufferHelper.getLong (this);
+    return ByteBufferHelper.getLong(this, order());
   }
   
   final public ByteBuffer putLong (long value)
   {
-    return ByteBufferHelper.putLong (this, value);
+    ByteBufferHelper.putLong (this, value, order());
+    return this;
   }
   
   final public long getLong (int index)
   {
-    return ByteBufferHelper.getLong (this, index);
+    return ByteBufferHelper.getLong (this, index, order());
   }
   
   final public ByteBuffer putLong (int index, long value)
   {
-    return ByteBufferHelper.putLong (this, index, value);
+    ByteBufferHelper.putLong (this, index, value, order());
+    return this;
   }
 
   final public float getFloat ()
   {
-    return ByteBufferHelper.getFloat (this);
+    return ByteBufferHelper.getFloat (this, order());
   }
   
   final public ByteBuffer putFloat (float value)
   {
-    return ByteBufferHelper.putFloat (this, value);
+    ByteBufferHelper.putFloat (this, value, order());
+    return this;
   }
   
-  final public float getFloat (int index)
+  public final float getFloat (int index)
   {
-    return ByteBufferHelper.getFloat (this, index);
+    return ByteBufferHelper.getFloat (this, index, order());
   }
 
-  public final ByteBuffer putFloat (int index, float value)
+  final public ByteBuffer putFloat (int index, float value)
   {
-    return ByteBufferHelper.putFloat (this, index, value);
+    ByteBufferHelper.putFloat (this, index, value, order());
+    return this;
   }
 
   final public double getDouble ()
   {
-    return ByteBufferHelper.getDouble (this);
+    return ByteBufferHelper.getDouble (this, order());
   }
 
   final public ByteBuffer putDouble (double value)
   {
-    return ByteBufferHelper.putDouble (this, value);
+    ByteBufferHelper.putDouble (this, value, order());
+    return this;
   }
   
   final public double getDouble (int index)
   {
-    return ByteBufferHelper.getDouble (this, index);
+    return ByteBufferHelper.getDouble (this, index, order());
   }
   
   final public ByteBuffer putDouble (int index, double value)
   {
-    return ByteBufferHelper.putDouble (this, index, value);
+    ByteBufferHelper.putDouble (this, index, value, order());
+    return this;
   }
 }
Index: java/nio/CharViewBufferImpl.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/CharViewBufferImpl.java,v
retrieving revision 1.1
diff -u -p -r1.1 CharViewBufferImpl.java
--- java/nio/CharViewBufferImpl.java	20 May 2003 08:58:31 -0000	1.1
+++ java/nio/CharViewBufferImpl.java	6 Feb 2004 17:45:50 -0000
@@ -1,5 +1,5 @@
 /* CharViewBufferImpl.java -- 
-   Copyright (C) 2003 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -40,54 +40,47 @@ package java.nio;
 
 class CharViewBufferImpl extends CharBuffer
 {
-  private boolean readOnly;
+  /** Position in bb (i.e. a byte offset) where this buffer starts. */
   private int offset;
   private ByteBuffer bb;
+  private boolean readOnly;
   private ByteOrder endian;
   
-  public CharViewBufferImpl (ByteBuffer bb, boolean readOnly)
-  {
-    super (bb.remaining () >> 1, bb.remaining () >> 1, bb.position (), 0);
-    this.bb = bb;
-    this.readOnly = readOnly;
-    // FIXME: What if this is called from CharByteBufferImpl and ByteBuffer has changed its endianess ?
-    this.endian = bb.order ();
-  }
-
   public CharViewBufferImpl (ByteBuffer bb, int offset, int capacity,
-                               int limit, int position, int mark,
-                               boolean readOnly)
+			     int limit, int position, int mark,
+			     boolean readOnly, ByteOrder endian)
   {
     super (limit >> 1, limit >> 1, position >> 1, mark >> 1);
     this.bb = bb;
     this.offset = offset;
     this.readOnly = readOnly;
-    // FIXME: What if this is called from CharViewBufferImpl and ByteBuffer has changed its endianess ?
-    this.endian = bb.order ();
+    this.endian = endian;
   }
 
   public char get ()
   {
-    char result = bb.getChar ((position () << 1) + offset);
-    position (position () + 1);
+    int p = position();
+    char result = ByteBufferHelper.getChar(bb, (p << 1) + offset, endian);
+    position(p + 1);
     return result;
   }
 
   public char get (int index)
   {
-    return bb.getChar ((index << 1) + offset);
+    return ByteBufferHelper.getChar(bb, (index << 1) + offset, endian);
   }
 
   public CharBuffer put (char value)
   {
-    bb.putChar ((position () << 1) + offset, value);
-    position (position () + 1);
+    int p = position();
+    ByteBufferHelper.putChar(bb, (p << 1) + offset, value, endian);
+    position(p + 1);
     return this;
   }
   
   public CharBuffer put (int index, char value)
   {
-    bb.putChar ((index << 1) + offset, value);
+    ByteBufferHelper.putChar(bb, (index << 1) + offset, value, endian);
     return this;
   }
 
@@ -95,59 +88,54 @@ class CharViewBufferImpl extends CharBuf
   {
     if (position () > 0)
       {
-        // Copy all data from position() to limit() to the beginning of the
-        // buffer, set position to end of data and limit to capacity
-        // XXX: This can surely be optimized, for direct and non-direct buffers
-        
         int count = limit () - position ();
-              
-        for (int i = 0; i < count; i++)
-          {
-            bb.putChar ((i >> 1) + offset,
-                          bb.getChar (((i + position ()) >> 1) + offset));
-          }
-
+	bb.shiftDown(offset, offset + 2 * position(), 2 * count);
         position (count);
         limit (capacity ());
       }
-
     return this;
   }
   
-  public CharBuffer duplicate ()
-  {
-    // Create a copy of this object that shares its content
-    // FIXME: mark is not correct
-    return new CharViewBufferImpl (bb, offset, capacity (), limit (),
-                                     position (), -1, isReadOnly ());
-  }
-  
   public CharBuffer slice ()
   {
     // Create a sliced copy of this object that shares its content.
     return new CharViewBufferImpl (bb, (position () >> 1) + offset,
-                                      remaining (), remaining (), 0, -1,
-                                     isReadOnly ());
+				   remaining (), remaining (), 0, -1,
+				   isReadOnly (), endian);
   }
   
+  CharBuffer duplicate (boolean readOnly)
+  {
+    int pos = position();
+    reset();
+    int mark = position();
+    position(pos);
+    return new CharViewBufferImpl (bb, offset, capacity(), limit(),
+                                     pos, mark, readOnly, endian);
+  }
+  
+  public CharBuffer duplicate ()
+  {
+    return duplicate(readOnly);
+  }
+
+  public CharBuffer asReadOnlyBuffer ()
+  {
+    return duplicate(true);
+  }
+
   public CharSequence subSequence (int start, int end)
   {
     if (start < 0
-        || start > length ()
         || end < start
         || end > length ())
       throw new IndexOutOfBoundsException ();
 
-    return new CharViewBufferImpl (bb, array_offset, capacity (), position () + end, position () + start, -1, isReadOnly ());
+    return new CharViewBufferImpl (bb, array_offset, capacity (),
+				   position () + end, position () + start,
+				   -1, isReadOnly (), endian);
   }
 
-  public CharBuffer asReadOnlyBuffer ()
-  {
-    // Create a copy of this object that shares its content and is read-only
-    return new CharViewBufferImpl (bb, (position () >> 1) + offset,
-                                     remaining (), remaining (), 0, -1, true);
-  }
-  
   public boolean isReadOnly ()
   {
     return readOnly;
@@ -160,6 +148,6 @@ class CharViewBufferImpl extends CharBuf
   
   public ByteOrder order ()
   {
-    return ByteOrder.LITTLE_ENDIAN;
+    return endian;
   }
 }
Index: java/nio/DirectByteBufferImpl.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/DirectByteBufferImpl.java,v
retrieving revision 1.6
diff -u -p -r1.6 DirectByteBufferImpl.java
--- java/nio/DirectByteBufferImpl.java	21 Oct 2003 12:55:02 -0000	1.6
+++ java/nio/DirectByteBufferImpl.java	6 Feb 2004 17:45:50 -0000
@@ -1,5 +1,5 @@
 /* DirectByteBufferImpl.java -- 
-   Copyright (C) 2003 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -117,18 +117,18 @@ class DirectByteBufferImpl extends ByteB
     return this;
   }
   
+  native void shiftDown (int dst_offset, int src_offset, int count);
+
   public ByteBuffer compact ()
   {
-    // FIXME this can sure be optimized using memcpy()  
-    int copied = 0;
-    
-    while (remaining () > 0)
+    int pos = position();
+    if (pos > 0)
       {
-	put (copied, get ());
-	copied++;
+	int count = remaining();
+	shiftDown(0, pos, count);
+	position(count);
+	limit(capacity());
       }
-
-    position (copied);
     return this;
   }
 
@@ -161,197 +161,163 @@ class DirectByteBufferImpl extends ByteB
 
   public CharBuffer asCharBuffer ()
   {
-    return new CharViewBufferImpl (this, position () + offset, remaining (), remaining (), 0, -1, isReadOnly ());
+    return new CharViewBufferImpl (this, position (), remaining (), remaining (), 0, -1, isReadOnly (), order());
   }
   
   public DoubleBuffer asDoubleBuffer ()
   {
-    return new DoubleViewBufferImpl (this, position () + offset, remaining (), remaining (), 0, -1, isReadOnly ());
+    return new DoubleViewBufferImpl (this, position (), remaining (), remaining (), 0, -1, isReadOnly (), order());
   }
   
   public FloatBuffer asFloatBuffer ()
   {
-    return new FloatViewBufferImpl (this, position () + offset, remaining (), remaining (), 0, -1, isReadOnly ());
+    return new FloatViewBufferImpl (this, position (), remaining (), remaining (), 0, -1, isReadOnly (), order());
   }
   
   public IntBuffer asIntBuffer ()
   {
-    return new IntViewBufferImpl (this, position () + offset, remaining (), remaining (), 0, -1, isReadOnly ());
+    return new IntViewBufferImpl (this, position (), remaining (), remaining (), 0, -1, isReadOnly (), order());
   }
   
   public LongBuffer asLongBuffer ()
   {
-    return new LongViewBufferImpl (this, position () + offset, remaining (), remaining (), 0, -1, isReadOnly ());
+    return new LongViewBufferImpl (this, position (), remaining (), remaining (), 0, -1, isReadOnly (), order());
   }
   
   public ShortBuffer asShortBuffer ()
   {
-    return new ShortViewBufferImpl (this, position () + offset, remaining (), remaining (), 0, -1, isReadOnly ());
+    return new ShortViewBufferImpl (this, position (), remaining (), remaining (), 0, -1, isReadOnly (), order());
   }
   
   final public char getChar ()
   {
-    // FIXME: this handles little endian only
-    return (char) (((get () & 0xff) << 8)
-                   + (get () & 0xff));
+    return ByteBufferHelper.getChar(this, order());
   }
   
   final public ByteBuffer putChar (char value)
   {
-    // FIXME: this handles little endian only
-    put ((byte) ((((int) value) & 0xff00) >> 8));
-    put ((byte) (((int) value) & 0x00ff));
+    ByteBufferHelper.putChar(this, value, order());
     return this;
   }
   
   final public char getChar (int index)
   {
-    // FIXME: this handles little endian only
-    return (char) (((get (index) & 0xff) << 8)
-                   + (get (index + 1) & 0xff));
+    return ByteBufferHelper.getChar(this, index, order());
   }
   
   final public ByteBuffer putChar (int index, char value)
   {
-    // FIXME: this handles little endian only
-    put (index, (byte) ((((int) value) & 0xff00) >> 8));
-    put (index + 1, (byte) (((int) value) & 0x00ff));
+    ByteBufferHelper.putChar(this, index, value, order());
     return this;
   }
 
   final public short getShort ()
   {
-    // FIXME: this handles little endian only
-    return (short) (((get () & 0xff) << 8)
-                    + (get () & 0xff));
+    return ByteBufferHelper.getShort(this, order());
   }
   
   final public ByteBuffer putShort (short value)
   {
-    // FIXME: this handles little endian only
-    put ((byte) ((((int) value) & 0xff00) >> 8));
-    put ((byte) (((int) value) & 0x00ff));
+    ByteBufferHelper.putShort(this, value, order());
     return this;
   }
   
   final public short getShort (int index)
   {
-    // FIXME: this handles little endian only
-    return (short) (((get (index) & 0xff) << 8)
-                    + (get (index + 1) & 0xff));
+    return ByteBufferHelper.getShort(this, index, order());
   }
   
   final public ByteBuffer putShort (int index, short value)
   {
-    // FIXME: this handles little endian only
-    put (index, (byte) ((((int) value) & 0xff00) >> 8));
-    put (index + 1, (byte) (((int) value) & 0x00ff));
+    ByteBufferHelper.putShort(this, index, value, order());
     return this;
   }
 
   final public int getInt ()
   {
-    // FIXME: this handles little endian only
-    return (int) (((get () & 0xff) << 24)
-                  + ((get () & 0xff) << 16)
-                  + ((get () & 0xff) << 8)
-                  + (get () & 0xff));
+    return ByteBufferHelper.getInt(this, order());
   }
   
   final public ByteBuffer putInt (int value)
   {
-    // FIXME: this handles little endian only
-    put ((byte) ((((int) value) & 0xff000000) >> 24));
-    put ((byte) ((((int) value) & 0x00ff0000) >> 16));
-    put ((byte) ((((int) value) & 0x0000ff00) >> 8));
-    put ((byte) (((int) value) & 0x000000ff));
+    ByteBufferHelper.putInt(this, value, order());
     return this;
   }
   
   final public int getInt (int index)
   {
-    // FIXME: this handles little endian only
-    return (int) (((get (index) & 0xff) << 24)
-                  + ((get (index + 1) & 0xff) << 16)
-                  + ((get (index + 2) & 0xff) << 8)
-                  + (get (index + 3) & 0xff));
+    return ByteBufferHelper.getInt(this, index, order());
   }
   
   final public ByteBuffer putInt (int index, int value)
   {
-    // FIXME: this handles little endian only
-    put (index, (byte) ((((int) value) & 0xff000000) >> 24));
-    put (index + 1, (byte) ((((int) value) & 0x00ff0000) >> 16));
-    put (index + 2, (byte) ((((int) value) & 0x0000ff00) >> 8));
-    put (index + 3, (byte) (((int) value) & 0x000000ff));
+    ByteBufferHelper.putInt(this, index, value, order());
     return this;
   }
 
   final public long getLong ()
   {
-    // FIXME: this handles little endian only
-    return (long) (((get () & 0xff) << 56)
-                   + ((get () & 0xff) << 48)
-                   + ((get () & 0xff) << 40)
-                   + ((get () & 0xff) << 32)
-                   + ((get () & 0xff) << 24)
-                   + ((get () & 0xff) << 16)
-                   + ((get () & 0xff) << 8)
-                   + (get () & 0xff));
+    return ByteBufferHelper.getLong(this, order());
   }
   
   final public ByteBuffer putLong (long value)
   {
-    return ByteBufferHelper.putLong (this, value);
+    ByteBufferHelper.putLong (this, value, order());
+    return this;
   }
   
   final public long getLong (int index)
   {
-    return ByteBufferHelper.getLong (this, index);
+    return ByteBufferHelper.getLong (this, index, order());
   }
   
   final public ByteBuffer putLong (int index, long value)
   {
-    return ByteBufferHelper.putLong (this, index, value);
+    ByteBufferHelper.putLong (this, index, value, order());
+    return this;
   }
 
   final public float getFloat ()
   {
-    return ByteBufferHelper.getFloat (this);
+    return ByteBufferHelper.getFloat (this, order());
   }
   
   final public ByteBuffer putFloat (float value)
   {
-    return ByteBufferHelper.putFloat (this, value);
+    ByteBufferHelper.putFloat (this, value, order());
+    return this;
   }
   
   public final float getFloat (int index)
   {
-    return ByteBufferHelper.getFloat (this, index);
+    return ByteBufferHelper.getFloat (this, index, order());
   }
 
   final public ByteBuffer putFloat (int index, float value)
   {
-    return ByteBufferHelper.putFloat (this, index, value);
+    ByteBufferHelper.putFloat (this, index, value, order());
+    return this;
   }
 
   final public double getDouble ()
   {
-    return ByteBufferHelper.getDouble (this);
+    return ByteBufferHelper.getDouble (this, order());
   }
 
   final public ByteBuffer putDouble (double value)
   {
-    return ByteBufferHelper.putDouble (this, value);
+    ByteBufferHelper.putDouble (this, value, order());
+    return this;
   }
   
   final public double getDouble (int index)
   {
-    return ByteBufferHelper.getDouble (this, index);
+    return ByteBufferHelper.getDouble (this, index, order());
   }
   
   final public ByteBuffer putDouble (int index, double value)
   {
-    return ByteBufferHelper.putDouble (this, index, value);
+    ByteBufferHelper.putDouble (this, index, value, order());
+    return this;
   }
 }
Index: java/nio/DoubleViewBufferImpl.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/DoubleViewBufferImpl.java,v
retrieving revision 1.1
diff -u -p -r1.1 DoubleViewBufferImpl.java
--- java/nio/DoubleViewBufferImpl.java	20 May 2003 08:58:31 -0000	1.1
+++ java/nio/DoubleViewBufferImpl.java	6 Feb 2004 17:45:50 -0000
@@ -1,5 +1,5 @@
 /* DoubleViewBufferImpl.java -- 
-   Copyright (C) 2003 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -40,54 +40,47 @@ package java.nio;
 
 class DoubleViewBufferImpl extends DoubleBuffer
 {
-  private boolean readOnly;
+  /** Position in bb (i.e. a byte offset) where this buffer starts. */
   private int offset;
   private ByteBuffer bb;
+  private boolean readOnly;
   private ByteOrder endian;
   
-  public DoubleViewBufferImpl (ByteBuffer bb, boolean readOnly)
-  {
-    super (bb.remaining () >> 3, bb.remaining () >> 3, bb.position (), 0);
-    this.bb = bb;
-    this.readOnly = readOnly;
-    // FIXME: What if this is called from DoubleByteBufferImpl and ByteBuffer has changed its endianess ?
-    this.endian = bb.order ();
-  }
-
   public DoubleViewBufferImpl (ByteBuffer bb, int offset, int capacity,
                                int limit, int position, int mark,
-                               boolean readOnly)
+                               boolean readOnly, ByteOrder endian)
   {
     super (limit >> 3, limit >> 3, position >> 3, mark >> 3);
     this.bb = bb;
     this.offset = offset;
     this.readOnly = readOnly;
-    // FIXME: What if this is called from DoubleViewBufferImpl and ByteBuffer has changed its endianess ?
-    this.endian = bb.order ();
+    this.endian = endian;
   }
 
   public double get ()
   {
-    double result = bb.getDouble ((position () << 3) + offset);
-    position (position () + 1);
+    int p = position();
+    double result = ByteBufferHelper.getDouble(bb, (p << 3) + offset, endian);
+    position(p + 1);
     return result;
   }
 
   public double get (int index)
   {
-    return bb.getDouble ((index << 3) + offset);
+    return ByteBufferHelper.getDouble(bb, (index << 3) + offset, endian);
   }
 
   public DoubleBuffer put (double value)
   {
-    bb.putDouble ((position () << 3) + offset, value);
-    position (position () + 1);
+    int p = position();
+    ByteBufferHelper.putDouble(bb, (p << 3) + offset, value, endian);
+    position(p + 1);
     return this;
   }
   
   public DoubleBuffer put (int index, double value)
   {
-    bb.putDouble ((index << 3) + offset, value);
+    ByteBufferHelper.putDouble(bb, (index << 3) + offset, value, endian);
     return this;
   }
 
@@ -95,48 +88,41 @@ class DoubleViewBufferImpl extends Doubl
   {
     if (position () > 0)
       {
-        // Copy all data from position() to limit() to the beginning of the
-        // buffer, set position to end of data and limit to capacity
-        // XXX: This can surely be optimized, for direct and non-direct buffers
-        
         int count = limit () - position ();
-              
-        for (int i = 0; i < count; i++)
-          {
-            bb.putDouble ((i >> 3) + offset,
-                          bb.getDouble (((i + position ()) >> 3) + offset));
-          }
-
+	bb.shiftDown(offset, offset + 8 * position(), 8 * count);
         position (count);
         limit (capacity ());
       }
-
     return this;
   }
   
-  public DoubleBuffer duplicate ()
+  public DoubleBuffer slice ()
   {
-    // Create a copy of this object that shares its content
-    // FIXME: mark is not correct
-    return new DoubleViewBufferImpl (bb, offset, capacity (), limit (),
-                                     position (), -1, isReadOnly ());
+    return new DoubleViewBufferImpl (bb, (position () >> 3) + offset,
+				     remaining(), remaining(), 0, -1,
+                                     readOnly, endian);
   }
   
-  public DoubleBuffer slice ()
+  DoubleBuffer duplicate (boolean readOnly)
   {
-    // Create a sliced copy of this object that shares its content.
-    return new DoubleViewBufferImpl (bb, (position () >> 3) + offset,
-                                      remaining (), remaining (), 0, -1,
-                                     isReadOnly ());
+    int pos = position();
+    reset();
+    int mark = position();
+    position(pos);
+    return new DoubleViewBufferImpl (bb, offset, capacity(), limit(),
+                                     pos, mark, readOnly, endian);
   }
   
+  public DoubleBuffer duplicate ()
+  {
+    return duplicate(readOnly);
+  }
+
   public DoubleBuffer asReadOnlyBuffer ()
   {
-    // Create a copy of this object that shares its content and is read-only
-    return new DoubleViewBufferImpl (bb, (position () >> 3) + offset,
-                                     remaining (), remaining (), 0, -1, true);
+    return duplicate(true);
   }
-  
+
   public boolean isReadOnly ()
   {
     return readOnly;
@@ -149,6 +135,6 @@ class DoubleViewBufferImpl extends Doubl
   
   public ByteOrder order ()
   {
-    return ByteOrder.LITTLE_ENDIAN;
+    return endian;
   }
 }
Index: java/nio/FloatViewBufferImpl.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/FloatViewBufferImpl.java,v
retrieving revision 1.1
diff -u -p -r1.1 FloatViewBufferImpl.java
--- java/nio/FloatViewBufferImpl.java	20 May 2003 08:58:31 -0000	1.1
+++ java/nio/FloatViewBufferImpl.java	6 Feb 2004 17:45:50 -0000
@@ -1,5 +1,5 @@
 /* FloatViewBufferImpl.java -- 
-   Copyright (C) 2003 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -40,54 +40,47 @@ package java.nio;
 
 class FloatViewBufferImpl extends FloatBuffer
 {
-  private boolean readOnly;
+  /** Position in bb (i.e. a byte offset) where this buffer starts. */
   private int offset;
   private ByteBuffer bb;
+  private boolean readOnly;
   private ByteOrder endian;
   
-  public FloatViewBufferImpl (ByteBuffer bb, boolean readOnly)
-  {
-    super (bb.remaining () >> 2, bb.remaining () >> 2, bb.position (), 0);
-    this.bb = bb;
-    this.readOnly = readOnly;
-    // FIXME: What if this is called from FloatByteBufferImpl and ByteBuffer has changed its endianess ?
-    this.endian = bb.order ();
-  }
-
   public FloatViewBufferImpl (ByteBuffer bb, int offset, int capacity,
-                               int limit, int position, int mark,
-                               boolean readOnly)
+			      int limit, int position, int mark,
+			      boolean readOnly, ByteOrder endian)
   {
     super (limit >> 2, limit >> 2, position >> 2, mark >> 2);
     this.bb = bb;
     this.offset = offset;
     this.readOnly = readOnly;
-    // FIXME: What if this is called from FloatViewBufferImpl and ByteBuffer has changed its endianess ?
-    this.endian = bb.order ();
+    this.endian = endian;
   }
 
   public float get ()
   {
-    float result = bb.getFloat ((position () << 2) + offset);
-    position (position () + 1);
+    int p = position();
+    float result = ByteBufferHelper.getFloat(bb, (p << 2) + offset, endian);
+    position(p + 1);
     return result;
   }
 
   public float get (int index)
   {
-    return bb.getFloat ((index << 2) + offset);
+    return ByteBufferHelper.getFloat(bb, (index << 2) + offset, endian);
   }
 
   public FloatBuffer put (float value)
   {
-    bb.putFloat ((position () << 2) + offset, value);
-    position (position () + 1);
+    int p = position();
+    ByteBufferHelper.putFloat(bb, (p << 2) + offset, value, endian);
+    position(p + 1);
     return this;
   }
   
   public FloatBuffer put (int index, float value)
   {
-    bb.putFloat ((index << 2) + offset, value);
+    ByteBufferHelper.putFloat(bb, (index << 2) + offset, value, endian);
     return this;
   }
 
@@ -95,48 +88,42 @@ class FloatViewBufferImpl extends FloatB
   {
     if (position () > 0)
       {
-        // Copy all data from position() to limit() to the beginning of the
-        // buffer, set position to end of data and limit to capacity
-        // XXX: This can surely be optimized, for direct and non-direct buffers
-        
         int count = limit () - position ();
-              
-        for (int i = 0; i < count; i++)
-          {
-            bb.putFloat ((i >> 2) + offset,
-                          bb.getFloat (((i + position ()) >> 2) + offset));
-          }
-
+	bb.shiftDown(offset, offset + 4 * position(), 4 * count);
         position (count);
         limit (capacity ());
       }
-
     return this;
   }
   
-  public FloatBuffer duplicate ()
-  {
-    // Create a copy of this object that shares its content
-    // FIXME: mark is not correct
-    return new FloatViewBufferImpl (bb, offset, capacity (), limit (),
-                                     position (), -1, isReadOnly ());
-  }
-  
   public FloatBuffer slice ()
   {
     // Create a sliced copy of this object that shares its content.
     return new FloatViewBufferImpl (bb, (position () >> 2) + offset,
-                                      remaining (), remaining (), 0, -1,
-                                     isReadOnly ());
+				    remaining(), remaining(), 0, -1,
+				    readOnly, endian);
   }
   
-  public FloatBuffer asReadOnlyBuffer ()
+  FloatBuffer duplicate (boolean readOnly)
   {
-    // Create a copy of this object that shares its content and is read-only
-    return new FloatViewBufferImpl (bb, (position () >> 2) + offset,
-                                     remaining (), remaining (), 0, -1, true);
+    int pos = position();
+    reset();
+    int mark = position();
+    position(pos);
+    return new FloatViewBufferImpl (bb, offset, capacity(), limit(),
+				    pos, mark, readOnly, endian);
   }
   
+  public FloatBuffer duplicate ()
+  {
+    return duplicate(readOnly);
+  }
+
+  public FloatBuffer asReadOnlyBuffer ()
+  {
+    return duplicate(true);
+  }
+
   public boolean isReadOnly ()
   {
     return readOnly;
@@ -149,6 +136,6 @@ class FloatViewBufferImpl extends FloatB
   
   public ByteOrder order ()
   {
-    return ByteOrder.LITTLE_ENDIAN;
+    return endian;
   }
 }
Index: java/nio/IntViewBufferImpl.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/IntViewBufferImpl.java,v
retrieving revision 1.1
diff -u -p -r1.1 IntViewBufferImpl.java
--- java/nio/IntViewBufferImpl.java	20 May 2003 08:58:31 -0000	1.1
+++ java/nio/IntViewBufferImpl.java	6 Feb 2004 17:45:50 -0000
@@ -1,5 +1,5 @@
 /* IntViewBufferImpl.java -- 
-   Copyright (C) 2003 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -40,54 +40,47 @@ package java.nio;
 
 class IntViewBufferImpl extends IntBuffer
 {
-  private boolean readOnly;
+  /** Position in bb (i.e. a byte offset) where this buffer starts. */
   private int offset;
   private ByteBuffer bb;
+  private boolean readOnly;
   private ByteOrder endian;
   
-  public IntViewBufferImpl (ByteBuffer bb, boolean readOnly)
-  {
-    super (bb.remaining () >> 2, bb.remaining () >> 2, bb.position (), 0);
-    this.bb = bb;
-    this.readOnly = readOnly;
-    // FIXME: What if this is called from IntByteBufferImpl and ByteBuffer has changed its endianess ?
-    this.endian = bb.order ();
-  }
-
   public IntViewBufferImpl (ByteBuffer bb, int offset, int capacity,
-                               int limit, int position, int mark,
-                               boolean readOnly)
+			    int limit, int position, int mark,
+			    boolean readOnly, ByteOrder endian)
   {
     super (limit >> 2, limit >> 2, position >> 2, mark >> 2);
     this.bb = bb;
     this.offset = offset;
     this.readOnly = readOnly;
-    // FIXME: What if this is called from IntViewBufferImpl and ByteBuffer has changed its endianess ?
-    this.endian = bb.order ();
+    this.endian = endian;
   }
 
   public int get ()
   {
-    int result = bb.getInt ((position () << 2) + offset);
-    position (position () + 1);
+    int p = position();
+    int result = ByteBufferHelper.getInt(bb, (p << 2) + offset, endian);
+    position(p + 1);
     return result;
   }
 
   public int get (int index)
   {
-    return bb.getInt ((index << 2) + offset);
+    return ByteBufferHelper.getInt(bb, (index << 2) + offset, endian);
   }
 
   public IntBuffer put (int value)
   {
-    bb.putInt ((position () << 2) + offset, value);
-    position (position () + 1);
+    int p = position();
+    ByteBufferHelper.putInt(bb, (p << 2) + offset, value, endian);
+    position(p + 1);
     return this;
   }
   
   public IntBuffer put (int index, int value)
   {
-    bb.putInt ((index << 2) + offset, value);
+    ByteBufferHelper.putInt(bb, (index << 2) + offset, value, endian);
     return this;
   }
 
@@ -95,48 +88,42 @@ class IntViewBufferImpl extends IntBuffe
   {
     if (position () > 0)
       {
-        // Copy all data from position() to limit() to the beginning of the
-        // buffer, set position to end of data and limit to capacity
-        // XXX: This can surely be optimized, for direct and non-direct buffers
-        
         int count = limit () - position ();
-              
-        for (int i = 0; i < count; i++)
-          {
-            bb.putInt ((i >> 2) + offset,
-                          bb.getInt (((i + position ()) >> 2) + offset));
-          }
-
+	bb.shiftDown(offset, offset + 4 * position(), 4 * count);
         position (count);
         limit (capacity ());
       }
-
     return this;
   }
   
-  public IntBuffer duplicate ()
-  {
-    // Create a copy of this object that shares its content
-    // FIXME: mark is not correct
-    return new IntViewBufferImpl (bb, offset, capacity (), limit (),
-                                     position (), -1, isReadOnly ());
-  }
-  
   public IntBuffer slice ()
   {
     // Create a sliced copy of this object that shares its content.
     return new IntViewBufferImpl (bb, (position () >> 2) + offset,
-                                      remaining (), remaining (), 0, -1,
-                                     isReadOnly ());
+				  remaining(), remaining(), 0, -1,
+				  readOnly, endian);
   }
   
-  public IntBuffer asReadOnlyBuffer ()
+  IntBuffer duplicate (boolean readOnly)
   {
-    // Create a copy of this object that shares its content and is read-only
-    return new IntViewBufferImpl (bb, (position () >> 2) + offset,
-                                     remaining (), remaining (), 0, -1, true);
+    int pos = position();
+    reset();
+    int mark = position();
+    position(pos);
+    return new IntViewBufferImpl (bb, offset, capacity(), limit(),
+				  pos, mark, readOnly, endian);
   }
   
+  public IntBuffer duplicate ()
+  {
+    return duplicate(readOnly);
+  }
+
+  public IntBuffer asReadOnlyBuffer ()
+  {
+    return duplicate(true);
+  }
+
   public boolean isReadOnly ()
   {
     return readOnly;
@@ -149,6 +136,6 @@ class IntViewBufferImpl extends IntBuffe
   
   public ByteOrder order ()
   {
-    return ByteOrder.LITTLE_ENDIAN;
+    return endian;
   }
 }
Index: java/nio/LongViewBufferImpl.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/LongViewBufferImpl.java,v
retrieving revision 1.1
diff -u -p -r1.1 LongViewBufferImpl.java
--- java/nio/LongViewBufferImpl.java	20 May 2003 08:58:31 -0000	1.1
+++ java/nio/LongViewBufferImpl.java	6 Feb 2004 17:45:50 -0000
@@ -1,5 +1,5 @@
 /* LongViewBufferImpl.java -- 
-   Copyright (C) 2003 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -40,54 +40,47 @@ package java.nio;
 
 class LongViewBufferImpl extends LongBuffer
 {
-  private boolean readOnly;
+  /** Position in bb (i.e. a byte offset) where this buffer starts. */
   private int offset;
   private ByteBuffer bb;
+  private boolean readOnly;
   private ByteOrder endian;
   
-  public LongViewBufferImpl (ByteBuffer bb, boolean readOnly)
-  {
-    super (bb.remaining () >> 3, bb.remaining () >> 3, bb.position (), 0);
-    this.bb = bb;
-    this.readOnly = readOnly;
-    // FIXME: What if this is called from LongByteBufferImpl and ByteBuffer has changed its endianess ?
-    this.endian = bb.order ();
-  }
-
   public LongViewBufferImpl (ByteBuffer bb, int offset, int capacity,
-                               int limit, int position, int mark,
-                               boolean readOnly)
+			     int limit, int position, int mark,
+			     boolean readOnly, ByteOrder endian)
   {
     super (limit >> 3, limit >> 3, position >> 3, mark >> 3);
     this.bb = bb;
     this.offset = offset;
     this.readOnly = readOnly;
-    // FIXME: What if this is called from LongViewBufferImpl and ByteBuffer has changed its endianess ?
-    this.endian = bb.order ();
+    this.endian = endian;
   }
 
   public long get ()
   {
-    long result = bb.getLong ((position () << 3) + offset);
-    position (position () + 1);
+    int p = position();
+    long result = ByteBufferHelper.getLong(bb, (p << 3) + offset, endian);
+    position(p + 1);
     return result;
   }
 
   public long get (int index)
   {
-    return bb.getLong ((index << 3) + offset);
+    return ByteBufferHelper.getLong(bb, (index << 3) + offset, endian);
   }
 
   public LongBuffer put (long value)
   {
-    bb.putLong ((position () << 3) + offset, value);
-    position (position () + 1);
+    int p = position();
+    ByteBufferHelper.putLong(bb, (p << 3) + offset, value, endian);
+    position(p + 1);
     return this;
   }
   
   public LongBuffer put (int index, long value)
   {
-    bb.putLong ((index << 3) + offset, value);
+    ByteBufferHelper.putLong(bb, (index << 3) + offset, value, endian);
     return this;
   }
 
@@ -95,48 +88,42 @@ class LongViewBufferImpl extends LongBuf
   {
     if (position () > 0)
       {
-        // Copy all data from position() to limit() to the beginning of the
-        // buffer, set position to end of data and limit to capacity
-        // XXX: This can surely be optimized, for direct and non-direct buffers
-        
         int count = limit () - position ();
-              
-        for (int i = 0; i < count; i++)
-          {
-            bb.putLong ((i >> 3) + offset,
-                          bb.getLong (((i + position ()) >> 3) + offset));
-          }
-
+	bb.shiftDown(offset, offset + 8 * position(), 8 * count);
         position (count);
         limit (capacity ());
       }
-
     return this;
   }
   
-  public LongBuffer duplicate ()
-  {
-    // Create a copy of this object that shares its content
-    // FIXME: mark is not correct
-    return new LongViewBufferImpl (bb, offset, capacity (), limit (),
-                                     position (), -1, isReadOnly ());
-  }
-  
   public LongBuffer slice ()
   {
     // Create a sliced copy of this object that shares its content.
     return new LongViewBufferImpl (bb, (position () >> 3) + offset,
-                                      remaining (), remaining (), 0, -1,
-                                     isReadOnly ());
+				   remaining(), remaining(), 0, -1,
+				   readOnly, endian);
   }
   
-  public LongBuffer asReadOnlyBuffer ()
+  LongBuffer duplicate (boolean readOnly)
   {
-    // Create a copy of this object that shares its content and is read-only
-    return new LongViewBufferImpl (bb, (position () >> 3) + offset,
-                                     remaining (), remaining (), 0, -1, true);
+    int pos = position();
+    reset();
+    int mark = position();
+    position(pos);
+    return new LongViewBufferImpl (bb, offset, capacity(), limit(),
+				   pos, mark, readOnly, endian);
   }
   
+  public LongBuffer duplicate ()
+  {
+    return duplicate(readOnly);
+  }
+
+  public LongBuffer asReadOnlyBuffer ()
+  {
+    return duplicate(true);
+  }
+
   public boolean isReadOnly ()
   {
     return readOnly;
@@ -149,6 +136,6 @@ class LongViewBufferImpl extends LongBuf
   
   public ByteOrder order ()
   {
-    return ByteOrder.LITTLE_ENDIAN;
+    return endian;
   }
 }
Index: java/nio/MappedByteBufferImpl.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/MappedByteBufferImpl.java,v
retrieving revision 1.4
diff -u -p -r1.4 MappedByteBufferImpl.java
--- java/nio/MappedByteBufferImpl.java	25 Sep 2003 06:43:52 -0000	1.4
+++ java/nio/MappedByteBufferImpl.java	6 Feb 2004 17:45:50 -0000
@@ -1,5 +1,5 @@
 /* MappedByteBufferImpl.java -- 
-   Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -111,15 +111,14 @@ public class MappedByteBufferImpl extend
 
   public ByteBuffer compact ()
   {
-    int copied = 0;
-    
-    while (remaining () > 0)
+    int pos = position();
+    if (pos > 0)
       {
-	put (copied, get ());
-	copied++;
+	int count = remaining();
+	shiftDown(0, pos, count);
+	position(count);
+	limit(capacity());
       }
-
-    position (copied);
     return this;
   }
 
@@ -145,151 +144,163 @@ public class MappedByteBufferImpl extend
 
   public CharBuffer asCharBuffer ()
   {
-    return new CharViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly ());
+    return new CharViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly (), order());
   }
 
   public ShortBuffer asShortBuffer ()
   {
-    return new ShortViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly ());
+    return new ShortViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly (), order());
   }
 
   public IntBuffer asIntBuffer ()
   {
-    return new IntViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly ());
+    return new IntViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly (), order());
   }
   
   public LongBuffer asLongBuffer ()
   {
-    return new LongViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly ());
+    return new LongViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly (), order());
   }
 
   public FloatBuffer asFloatBuffer ()
   {
-    return new FloatViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly ());
+    return new FloatViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly (), order());
   }
 
   public DoubleBuffer asDoubleBuffer ()
   {
-    return new DoubleViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly ());
+    return new DoubleViewBufferImpl (this, position (), remaining(), remaining (), 0, -1, isReadOnly (), order());
   }
 
-  public final char getChar()
+  final public char getChar ()
   {
-    return ByteBufferHelper.getChar (this);
+    return ByteBufferHelper.getChar(this, order());
   }
   
-  public final ByteBuffer putChar (char value)
+  final public ByteBuffer putChar (char value)
   {
-    return ByteBufferHelper.putChar (this, value);
+    ByteBufferHelper.putChar(this, value, order());
+    return this;
   }
   
-  public final char getChar (int index)
+  final public char getChar (int index)
   {
-    return ByteBufferHelper.getChar (this, index);
+    return ByteBufferHelper.getChar(this, index, order());
   }
   
-  public final ByteBuffer putChar (int index, char value)
+  final public ByteBuffer putChar (int index, char value)
   {
-    return ByteBufferHelper.putChar (this, index, value);
+    ByteBufferHelper.putChar(this, index, value, order());
+    return this;
   }
 
-  public final short getShort()
+  final public short getShort ()
   {
-    return ByteBufferHelper.getShort (this);
+    return ByteBufferHelper.getShort(this, order());
   }
   
-  public final ByteBuffer putShort (short value)
+  final public ByteBuffer putShort (short value)
   {
-    return ByteBufferHelper.putShort (this, value);
+    ByteBufferHelper.putShort(this, value, order());
+    return this;
   }
   
-  public final short getShort (int index)
+  final public short getShort (int index)
   {
-    return ByteBufferHelper.getShort (this, index);
+    return ByteBufferHelper.getShort(this, index, order());
   }
   
-  public final ByteBuffer putShort (int index, short value)
+  final public ByteBuffer putShort (int index, short value)
   {
-    return ByteBufferHelper.putShort (this, index, value);
+    ByteBufferHelper.putShort(this, index, value, order());
+    return this;
   }
 
-  public final int getInt()
+  final public int getInt ()
   {
-    return ByteBufferHelper.getInt (this);
+    return ByteBufferHelper.getInt(this, order());
   }
   
-  public final ByteBuffer putInt (int value)
+  final public ByteBuffer putInt (int value)
   {
-    return ByteBufferHelper.putInt (this, value);
+    ByteBufferHelper.putInt(this, value, order());
+    return this;
   }
   
-  public final int getInt (int index)
+  final public int getInt (int index)
   {
-    return ByteBufferHelper.getInt (this, index);
+    return ByteBufferHelper.getInt(this, index, order());
   }
   
-  public final ByteBuffer putInt (int index, int value)
+  final public ByteBuffer putInt (int index, int value)
   {
-    return ByteBufferHelper.putInt (this, index, value);
+    ByteBufferHelper.putInt(this, index, value, order());
+    return this;
   }
 
-  public final long getLong()
+  final public long getLong ()
   {
-    return ByteBufferHelper.getLong (this);
+    return ByteBufferHelper.getLong(this, order());
   }
   
-  public final ByteBuffer putLong (long value)
+  final public ByteBuffer putLong (long value)
   {
-    return ByteBufferHelper.putLong (this, value);
+    ByteBufferHelper.putLong (this, value, order());
+    return this;
   }
   
-  public final long getLong (int index)
+  final public long getLong (int index)
   {
-    return ByteBufferHelper.getLong (this, index);
+    return ByteBufferHelper.getLong (this, index, order());
   }
   
-  public final ByteBuffer putLong (int index, long value)
+  final public ByteBuffer putLong (int index, long value)
   {
-    return ByteBufferHelper.putLong (this, index, value);
+    ByteBufferHelper.putLong (this, index, value, order());
+    return this;
   }
 
-  public final float getFloat()
+  final public float getFloat ()
   {
-    return ByteBufferHelper.getFloat (this);
+    return ByteBufferHelper.getFloat (this, order());
   }
   
-  public final ByteBuffer putFloat (float value)
+  final public ByteBuffer putFloat (float value)
   {
-    return ByteBufferHelper.putFloat (this, value);
+    ByteBufferHelper.putFloat (this, value, order());
+    return this;
   }
   
   public final float getFloat (int index)
   {
-    return ByteBufferHelper.getFloat (this, index);
+    return ByteBufferHelper.getFloat (this, index, order());
   }
 
-  public final ByteBuffer putFloat (int index, float value)
+  final public ByteBuffer putFloat (int index, float value)
   {
-    return ByteBufferHelper.putFloat (this, index, value);
+    ByteBufferHelper.putFloat (this, index, value, order());
+    return this;
   }
 
-  public final double getDouble()
+  final public double getDouble ()
   {
-    return ByteBufferHelper.getDouble (this);
+    return ByteBufferHelper.getDouble (this, order());
   }
 
-  public final ByteBuffer putDouble (double value)
+  final public ByteBuffer putDouble (double value)
   {
-    return ByteBufferHelper.putDouble (this, value);
+    ByteBufferHelper.putDouble (this, value, order());
+    return this;
   }
   
-  public final double getDouble (int index)
+  final public double getDouble (int index)
   {
-    return ByteBufferHelper.getDouble (this, index);
+    return ByteBufferHelper.getDouble (this, index, order());
   }
   
-  public final ByteBuffer putDouble (int index, double value)
+  final public ByteBuffer putDouble (int index, double value)
   {
-    return ByteBufferHelper.putDouble (this, index, value);
+    ByteBufferHelper.putDouble (this, index, value, order());
+    return this;
   }
 }
Index: java/nio/ShortViewBufferImpl.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/ShortViewBufferImpl.java,v
retrieving revision 1.1
diff -u -p -r1.1 ShortViewBufferImpl.java
--- java/nio/ShortViewBufferImpl.java	20 May 2003 08:58:31 -0000	1.1
+++ java/nio/ShortViewBufferImpl.java	6 Feb 2004 17:45:50 -0000
@@ -1,5 +1,5 @@
 /* ShortViewBufferImpl.java -- 
-   Copyright (C) 2003 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -40,54 +40,47 @@ package java.nio;
 
 class ShortViewBufferImpl extends ShortBuffer
 {
-  private boolean readOnly;
+  /** Position in bb (i.e. a byte offset) where this buffer starts. */
   private int offset;
   private ByteBuffer bb;
+  private boolean readOnly;
   private ByteOrder endian;
   
-  public ShortViewBufferImpl (ByteBuffer bb, boolean readOnly)
-  {
-    super (bb.remaining () >> 1, bb.remaining () >> 1, bb.position (), 0);
-    this.bb = bb;
-    this.readOnly = readOnly;
-    // FIXME: What if this is called from ShortByteBufferImpl and ByteBuffer has changed its endianess ?
-    this.endian = bb.order ();
-  }
-
   public ShortViewBufferImpl (ByteBuffer bb, int offset, int capacity,
-                               int limit, int position, int mark,
-                               boolean readOnly)
+			      int limit, int position, int mark,
+			      boolean readOnly, ByteOrder endian)
   {
     super (limit >> 1, limit >> 1, position >> 1, mark >> 1);
     this.bb = bb;
     this.offset = offset;
     this.readOnly = readOnly;
-    // FIXME: What if this is called from ShortViewBufferImpl and ByteBuffer has changed its endianess ?
-    this.endian = bb.order ();
+    this.endian = endian;
   }
 
   public short get ()
   {
-    short result = bb.getShort ((position () << 1) + offset);
-    position (position () + 1);
+    int p = position();
+    short result = ByteBufferHelper.getShort(bb, (p << 1) + offset, endian);
+    position(p + 1);
     return result;
   }
 
   public short get (int index)
   {
-    return bb.getShort ((index << 1) + offset);
+    return ByteBufferHelper.getShort(bb, (index << 1) + offset, endian);
   }
 
   public ShortBuffer put (short value)
   {
-    bb.putShort ((position () << 1) + offset, value);
-    position (position () + 1);
+    int p = position();
+    ByteBufferHelper.putShort(bb, (p << 1) + offset, value, endian);
+    position(p + 1);
     return this;
   }
   
   public ShortBuffer put (int index, short value)
   {
-    bb.putShort ((index << 1) + offset, value);
+    ByteBufferHelper.putShort(bb, (index << 1) + offset, value, endian);
     return this;
   }
 
@@ -95,48 +88,42 @@ class ShortViewBufferImpl extends ShortB
   {
     if (position () > 0)
       {
-        // Copy all data from position() to limit() to the beginning of the
-        // buffer, set position to end of data and limit to capacity
-        // XXX: This can surely be optimized, for direct and non-direct buffers
-        
         int count = limit () - position ();
-              
-        for (int i = 0; i < count; i++)
-          {
-            bb.putShort ((i >> 1) + offset,
-                          bb.getShort (((i + position ()) >> 1) + offset));
-          }
-
+	bb.shiftDown(offset, offset + 2 * position(), 2 * count);
         position (count);
         limit (capacity ());
       }
-
     return this;
   }
   
-  public ShortBuffer duplicate ()
-  {
-    // Create a copy of this object that shares its content
-    // FIXME: mark is not correct
-    return new ShortViewBufferImpl (bb, offset, capacity (), limit (),
-                                     position (), -1, isReadOnly ());
-  }
-  
   public ShortBuffer slice ()
   {
     // Create a sliced copy of this object that shares its content.
     return new ShortViewBufferImpl (bb, (position () >> 1) + offset,
-                                      remaining (), remaining (), 0, -1,
-                                     isReadOnly ());
+				    remaining(), remaining(), 0, -1,
+				    readOnly, endian);
   }
   
-  public ShortBuffer asReadOnlyBuffer ()
+  ShortBuffer duplicate (boolean readOnly)
   {
-    // Create a copy of this object that shares its content and is read-only
-    return new ShortViewBufferImpl (bb, (position () >> 1) + offset,
-                                     remaining (), remaining (), 0, -1, true);
+    int pos = position();
+    reset();
+    int mark = position();
+    position(pos);
+    return new ShortViewBufferImpl (bb, offset, capacity(), limit(),
+				    pos, mark, readOnly, endian);
   }
   
+  public ShortBuffer duplicate ()
+  {
+    return duplicate(readOnly);
+  }
+
+  public ShortBuffer asReadOnlyBuffer ()
+  {
+    return duplicate(true);
+  }
+
   public boolean isReadOnly ()
   {
     return readOnly;
@@ -149,6 +136,6 @@ class ShortViewBufferImpl extends ShortB
   
   public ByteOrder order ()
   {
-    return ByteOrder.LITTLE_ENDIAN;
+    return endian;
   }
 }
Index: java/nio/natDirectByteBufferImpl.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/natDirectByteBufferImpl.cc,v
retrieving revision 1.2
diff -u -p -r1.2 natDirectByteBufferImpl.cc
--- java/nio/natDirectByteBufferImpl.cc	17 Jun 2003 19:09:56 -0000	1.2
+++ java/nio/natDirectByteBufferImpl.cc	6 Feb 2004 17:45:50 -0000
@@ -43,3 +43,12 @@ java::nio::DirectByteBufferImpl::putImpl
   jbyte* pointer = reinterpret_cast<jbyte*> (address) + offset + index;
   *pointer = value;
 }
+
+void
+java::nio::DirectByteBufferImpl::shiftDown
+(jint dst_offset, jint src_offset, jint count)
+{
+  jbyte* dst = reinterpret_cast<jbyte*> (address) + offset + dst_offset;
+  jbyte* src = reinterpret_cast<jbyte*> (address) + offset + src_offset;
+  ::memmove(dst, src, count);
+}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]