8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN
authorbpb
Wed, 15 Jul 2015 10:43:07 -0700
changeset 31723 2e16a59cc5cb
parent 31722 73d3dca7389b
child 31724 f6f1365b416f
8065570: (bf spec) ByteBuffer.slice() should make it clear that the initial order is BIG_ENDIAN Summary: Refine documentation of allocate*(), wrap(), slice(), duplicate(), asReadOnlyBuffer(), and as{Type}Buffer() to explcitly state the byte order of the created buffer. Reviewed-by: alanb
jdk/src/java.base/share/classes/java/nio/X-Buffer-bin.java.template
jdk/src/java.base/share/classes/java/nio/X-Buffer.java.template
jdk/test/java/nio/Buffer/Order-X.java.template
jdk/test/java/nio/Buffer/Order.java
jdk/test/java/nio/Buffer/OrderChar.java
jdk/test/java/nio/Buffer/OrderDouble.java
jdk/test/java/nio/Buffer/OrderFloat.java
jdk/test/java/nio/Buffer/OrderInt.java
jdk/test/java/nio/Buffer/OrderLong.java
jdk/test/java/nio/Buffer/OrderShort.java
jdk/test/java/nio/Buffer/genOrder.sh
--- a/jdk/src/java.base/share/classes/java/nio/X-Buffer-bin.java.template	Wed Jul 15 18:42:12 2015 +0100
+++ b/jdk/src/java.base/share/classes/java/nio/X-Buffer-bin.java.template	Wed Jul 15 10:43:07 2015 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2002, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -119,9 +119,10 @@
      *
      * <p> The new buffer's position will be zero, its capacity and its limit
      * will be the number of bytes remaining in this buffer divided by
-     * $nbytes$, and its mark will be undefined.  The new buffer will be direct
-     * if, and only if, this buffer is direct, and it will be read-only if, and
-     * only if, this buffer is read-only.  </p>
+     * $nbytes$, its mark will be undefined, and its byte order will be that
+     * of the byte buffer at the moment the view is created.  The new buffer
+     * will be direct if, and only if, this buffer is direct, and it will be
+     * read-only if, and only if, this buffer is read-only.  </p>
      *
      * @return  A new $type$ buffer
      */
--- a/jdk/src/java.base/share/classes/java/nio/X-Buffer.java.template	Wed Jul 15 18:42:12 2015 +0100
+++ b/jdk/src/java.base/share/classes/java/nio/X-Buffer.java.template	Wed Jul 15 10:43:07 2015 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -295,8 +295,9 @@
      * Allocates a new direct $type$ buffer.
      *
      * <p> The new buffer's position will be zero, its limit will be its
-     * capacity, its mark will be undefined, and each of its elements will be
-     * initialized to zero.  Whether or not it has a
+     * capacity, its mark will be undefined, each of its elements will be
+     * initialized to zero, and its byte order will be
+     * {@link ByteOrder#BIG_ENDIAN BIG_ENDIAN}.  Whether or not it has a
      * {@link #hasArray backing array} is unspecified.
      *
      * @param  capacity
@@ -317,9 +318,16 @@
      * Allocates a new $type$ buffer.
      *
      * <p> The new buffer's position will be zero, its limit will be its
-     * capacity, its mark will be undefined, and each of its elements will be
-     * initialized to zero.  It will have a {@link #array backing array},
-     * and its {@link #arrayOffset array offset} will be zero.
+     * capacity, its mark will be undefined, each of its elements will be
+     * initialized to zero, and its byte order will be
+#if[byte]
+     * {@link ByteOrder#BIG_ENDIAN BIG_ENDIAN}.
+#else[byte]
+     * the {@link ByteOrder#nativeOrder native order} of the underlying
+     * hardware.
+#end[byte]
+     * It will have a {@link #array backing array}, and its
+     * {@link #arrayOffset array offset} will be zero.
      *
      * @param  capacity
      *         The new buffer's capacity, in $type$s
@@ -342,8 +350,15 @@
      * that is, modifications to the buffer will cause the array to be modified
      * and vice versa.  The new buffer's capacity will be
      * <tt>array.length</tt>, its position will be <tt>offset</tt>, its limit
-     * will be <tt>offset + length</tt>, and its mark will be undefined.  Its
-     * {@link #array backing array} will be the given array, and
+     * will be <tt>offset + length</tt>, its mark will be undefined, and its
+     * byte order will be
+#if[byte]
+     * {@link ByteOrder#BIG_ENDIAN BIG_ENDIAN}.
+#else[byte]
+     * the {@link ByteOrder#nativeOrder native order} of the underlying
+     * hardware.
+#end[byte]
+     * Its {@link #array backing array} will be the given array, and
      * its {@link #arrayOffset array offset} will be zero.  </p>
      *
      * @param  array
@@ -382,10 +397,16 @@
      * <p> The new buffer will be backed by the given $type$ array;
      * that is, modifications to the buffer will cause the array to be modified
      * and vice versa.  The new buffer's capacity and limit will be
-     * <tt>array.length</tt>, its position will be zero, and its mark will be
-     * undefined.  Its {@link #array backing array} will be the
-     * given array, and its {@link #arrayOffset array offset} will
-     * be zero.  </p>
+     * <tt>array.length</tt>, its position will be zero, its mark will be
+     * undefined, and its byte order will be
+#if[byte]
+     * {@link ByteOrder#BIG_ENDIAN BIG_ENDIAN}.
+#else[byte]
+     * the {@link ByteOrder#nativeOrder native order} of the underlying
+     * hardware.
+#end[byte]
+     * Its {@link #array backing array} will be the given array, and its
+     * {@link #arrayOffset array offset} will be zero.  </p>
      *
      * @param  array
      *         The array that will back this buffer
@@ -499,10 +520,15 @@
      * values will be independent.
      *
      * <p> The new buffer's position will be zero, its capacity and its limit
-     * will be the number of $type$s remaining in this buffer, and its mark
-     * will be undefined.  The new buffer will be direct if, and only if, this
-     * buffer is direct, and it will be read-only if, and only if, this buffer
-     * is read-only.  </p>
+     * will be the number of $type$s remaining in this buffer, its mark will be
+     * undefined, and its byte order will be
+#if[byte]
+     * {@link ByteOrder#BIG_ENDIAN BIG_ENDIAN}.
+#else[byte]
+     * identical to that of this buffer.
+#end[byte]
+     * The new buffer will be direct if, and only if, this buffer is direct, and
+     * it will be read-only if, and only if, this buffer is read-only.  </p>
      *
      * @return  The new $type$ buffer
      */
@@ -516,10 +542,15 @@
      * versa; the two buffers' position, limit, and mark values will be
      * independent.
      *
-     * <p> The new buffer's capacity, limit, position, and mark values will be
-     * identical to those of this buffer.  The new buffer will be direct if,
-     * and only if, this buffer is direct, and it will be read-only if, and
-     * only if, this buffer is read-only.  </p>
+     * <p> The new buffer's capacity, limit, position,
+#if[byte]
+     * and mark values will be identical to those of this buffer, and its byte
+     * order will be {@link ByteOrder#BIG_ENDIAN BIG_ENDIAN}.
+#else[byte]
+     * mark values, and byte order will be identical to those of this buffer.
+#end[byte]
+     * The new buffer will be direct if, and only if, this buffer is direct, and
+     * it will be read-only if, and only if, this buffer is read-only.  </p>
      *
      * @return  The new $type$ buffer
      */
@@ -535,8 +566,13 @@
      * content to be modified.  The two buffers' position, limit, and mark
      * values will be independent.
      *
-     * <p> The new buffer's capacity, limit, position, and mark values will be
-     * identical to those of this buffer.
+     * <p> The new buffer's capacity, limit, position,
+#if[byte]
+     * and mark values will be identical to those of this buffer, and its byte
+     * order will be {@link ByteOrder#BIG_ENDIAN BIG_ENDIAN}.
+#else[byte]
+     * mark values, and byte order will be identical to those of this buffer.
+#end[byte]
      *
      * <p> If this buffer is itself read-only then this method behaves in
      * exactly the same way as the {@link #duplicate duplicate} method.  </p>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/nio/Buffer/Order-X.java.template	Wed Jul 15 10:43:07 2015 -0700
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* Type-specific source code for unit test
+ *
+ * Regenerate the OrderX classes via genOrder.sh whenever this file changes.
+ * We check in the generated source files so that the test tree can be used
+ * independently of the rest of the source tree.
+ */
+
+#warn This file is preprocessed before being compiled
+
+import java.nio.*;
+
+public class Order$Type$ extends Order {
+    private static void ck$Type$Buffer($Type$Buffer buf, ByteOrder expected) {
+        ck(buf.asReadOnlyBuffer().order(), expected);
+        ck(buf.duplicate().order(), expected);
+        ck(buf.slice().order(), expected);
+    }
+
+    static void ck$Type$Buffer() {
+        $type$[] array = new $type$[LENGTH];
+        $Type$Buffer buf = $Type$Buffer.wrap(array);
+        ck(buf.order(), nord);
+        ck$Type$Buffer(buf, nord);
+
+        buf = $Type$Buffer.wrap(array, LENGTH/2, LENGTH/2);
+        ck(buf.order(), nord);
+        ck$Type$Buffer(buf, nord);
+
+        buf = $Type$Buffer.allocate(LENGTH);
+        ck(buf.order(), nord);
+        ck$Type$Buffer(buf, nord);
+
+        ck$Type$Buffer(ByteBuffer.allocate(LENGTH).as$Type$Buffer(), be);
+        ck$Type$Buffer(ByteBuffer.allocateDirect(LENGTH).as$Type$Buffer(), be);
+    }
+}
--- a/jdk/test/java/nio/Buffer/Order.java	Wed Jul 15 18:42:12 2015 +0100
+++ b/jdk/test/java/nio/Buffer/Order.java	Wed Jul 15 10:43:07 2015 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,10 +22,10 @@
  */
 
 /* @test
+ * @bug 8065570
  * @summary Unit test for X-Buffer.order methods
  */
 
-import java.io.*;
 import java.nio.*;
 
 
@@ -35,6 +35,8 @@
     static final ByteOrder le = ByteOrder.LITTLE_ENDIAN;
     static final ByteOrder nord = ByteOrder.nativeOrder();
 
+    protected static final int LENGTH = 16;
+
     static void ck(ByteOrder ord, ByteOrder expected) {
         if (ord != expected)
             throw new RuntimeException("Got " + ord
@@ -55,18 +57,33 @@
         ckViews(bb, be);
         bb.order(le);
         ckViews(bb, le);
+
+        if (bb.hasArray()) {
+            byte[] array = bb.array();
+            ck(ByteBuffer.wrap(array, LENGTH/2, LENGTH/2).order(), be);
+            ck(ByteBuffer.wrap(array).order(), be);
+            ck(bb.asReadOnlyBuffer().order(), be);
+            ck(bb.duplicate().order(), be);
+            ck(bb.slice().order(), be);
+        }
     }
 
     public static void main(String args[]) throws Exception {
 
-        ck(ByteBuffer.allocate(10).order(), be);
-        ck(ByteBuffer.allocateDirect(10).order(), be);
-        ck(ByteBuffer.allocate(10).order(be).order(), be);
-        ck(ByteBuffer.allocate(10).order(le).order(), le);
+        ck(ByteBuffer.allocate(LENGTH).order(), be);
+        ck(ByteBuffer.allocateDirect(LENGTH).order(), be);
+        ck(ByteBuffer.allocate(LENGTH).order(be).order(), be);
+        ck(ByteBuffer.allocate(LENGTH).order(le).order(), le);
 
-        ckByteBuffer(ByteBuffer.allocate(10));
-        ckByteBuffer(ByteBuffer.allocateDirect(10));
+        ckByteBuffer(ByteBuffer.allocate(LENGTH));
+        ckByteBuffer(ByteBuffer.allocateDirect(LENGTH));
 
+        OrderChar.ckCharBuffer();
+        OrderShort.ckShortBuffer();
+        OrderInt.ckIntBuffer();
+        OrderLong.ckLongBuffer();
+        OrderFloat.ckFloatBuffer();
+        OrderDouble.ckDoubleBuffer();
     }
 
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/nio/Buffer/OrderChar.java	Wed Jul 15 10:43:07 2015 -0700
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* Type-specific source code for unit test
+ *
+ * Regenerate the OrderX classes via genOrder.sh whenever this file changes.
+ * We check in the generated source files so that the test tree can be used
+ * independently of the rest of the source tree.
+ */
+
+// -- This file was mechanically generated: Do not edit! -- //
+
+import java.nio.*;
+
+public class OrderChar extends Order {
+    private static void ckCharBuffer(CharBuffer buf, ByteOrder expected) {
+        ck(buf.asReadOnlyBuffer().order(), expected);
+        ck(buf.duplicate().order(), expected);
+        ck(buf.slice().order(), expected);
+    }
+
+    static void ckCharBuffer() {
+        char[] array = new char[LENGTH];
+        CharBuffer buf = CharBuffer.wrap(array);
+        ck(buf.order(), nord);
+        ckCharBuffer(buf, nord);
+
+        buf = CharBuffer.wrap(array, LENGTH/2, LENGTH/2);
+        ck(buf.order(), nord);
+        ckCharBuffer(buf, nord);
+
+        buf = CharBuffer.allocate(LENGTH);
+        ck(buf.order(), nord);
+        ckCharBuffer(buf, nord);
+
+        ckCharBuffer(ByteBuffer.allocate(LENGTH).asCharBuffer(), be);
+        ckCharBuffer(ByteBuffer.allocateDirect(LENGTH).asCharBuffer(), be);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/nio/Buffer/OrderDouble.java	Wed Jul 15 10:43:07 2015 -0700
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* Type-specific source code for unit test
+ *
+ * Regenerate the OrderX classes via genOrder.sh whenever this file changes.
+ * We check in the generated source files so that the test tree can be used
+ * independently of the rest of the source tree.
+ */
+
+// -- This file was mechanically generated: Do not edit! -- //
+
+import java.nio.*;
+
+public class OrderDouble extends Order {
+    private static void ckDoubleBuffer(DoubleBuffer buf, ByteOrder expected) {
+        ck(buf.asReadOnlyBuffer().order(), expected);
+        ck(buf.duplicate().order(), expected);
+        ck(buf.slice().order(), expected);
+    }
+
+    static void ckDoubleBuffer() {
+        double[] array = new double[LENGTH];
+        DoubleBuffer buf = DoubleBuffer.wrap(array);
+        ck(buf.order(), nord);
+        ckDoubleBuffer(buf, nord);
+
+        buf = DoubleBuffer.wrap(array, LENGTH/2, LENGTH/2);
+        ck(buf.order(), nord);
+        ckDoubleBuffer(buf, nord);
+
+        buf = DoubleBuffer.allocate(LENGTH);
+        ck(buf.order(), nord);
+        ckDoubleBuffer(buf, nord);
+
+        ckDoubleBuffer(ByteBuffer.allocate(LENGTH).asDoubleBuffer(), be);
+        ckDoubleBuffer(ByteBuffer.allocateDirect(LENGTH).asDoubleBuffer(), be);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/nio/Buffer/OrderFloat.java	Wed Jul 15 10:43:07 2015 -0700
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* Type-specific source code for unit test
+ *
+ * Regenerate the OrderX classes via genOrder.sh whenever this file changes.
+ * We check in the generated source files so that the test tree can be used
+ * independently of the rest of the source tree.
+ */
+
+// -- This file was mechanically generated: Do not edit! -- //
+
+import java.nio.*;
+
+public class OrderFloat extends Order {
+    private static void ckFloatBuffer(FloatBuffer buf, ByteOrder expected) {
+        ck(buf.asReadOnlyBuffer().order(), expected);
+        ck(buf.duplicate().order(), expected);
+        ck(buf.slice().order(), expected);
+    }
+
+    static void ckFloatBuffer() {
+        float[] array = new float[LENGTH];
+        FloatBuffer buf = FloatBuffer.wrap(array);
+        ck(buf.order(), nord);
+        ckFloatBuffer(buf, nord);
+
+        buf = FloatBuffer.wrap(array, LENGTH/2, LENGTH/2);
+        ck(buf.order(), nord);
+        ckFloatBuffer(buf, nord);
+
+        buf = FloatBuffer.allocate(LENGTH);
+        ck(buf.order(), nord);
+        ckFloatBuffer(buf, nord);
+
+        ckFloatBuffer(ByteBuffer.allocate(LENGTH).asFloatBuffer(), be);
+        ckFloatBuffer(ByteBuffer.allocateDirect(LENGTH).asFloatBuffer(), be);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/nio/Buffer/OrderInt.java	Wed Jul 15 10:43:07 2015 -0700
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* Type-specific source code for unit test
+ *
+ * Regenerate the OrderX classes via genOrder.sh whenever this file changes.
+ * We check in the generated source files so that the test tree can be used
+ * independently of the rest of the source tree.
+ */
+
+// -- This file was mechanically generated: Do not edit! -- //
+
+import java.nio.*;
+
+public class OrderInt extends Order {
+    private static void ckIntBuffer(IntBuffer buf, ByteOrder expected) {
+        ck(buf.asReadOnlyBuffer().order(), expected);
+        ck(buf.duplicate().order(), expected);
+        ck(buf.slice().order(), expected);
+    }
+
+    static void ckIntBuffer() {
+        int[] array = new int[LENGTH];
+        IntBuffer buf = IntBuffer.wrap(array);
+        ck(buf.order(), nord);
+        ckIntBuffer(buf, nord);
+
+        buf = IntBuffer.wrap(array, LENGTH/2, LENGTH/2);
+        ck(buf.order(), nord);
+        ckIntBuffer(buf, nord);
+
+        buf = IntBuffer.allocate(LENGTH);
+        ck(buf.order(), nord);
+        ckIntBuffer(buf, nord);
+
+        ckIntBuffer(ByteBuffer.allocate(LENGTH).asIntBuffer(), be);
+        ckIntBuffer(ByteBuffer.allocateDirect(LENGTH).asIntBuffer(), be);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/nio/Buffer/OrderLong.java	Wed Jul 15 10:43:07 2015 -0700
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* Type-specific source code for unit test
+ *
+ * Regenerate the OrderX classes via genOrder.sh whenever this file changes.
+ * We check in the generated source files so that the test tree can be used
+ * independently of the rest of the source tree.
+ */
+
+// -- This file was mechanically generated: Do not edit! -- //
+
+import java.nio.*;
+
+public class OrderLong extends Order {
+    private static void ckLongBuffer(LongBuffer buf, ByteOrder expected) {
+        ck(buf.asReadOnlyBuffer().order(), expected);
+        ck(buf.duplicate().order(), expected);
+        ck(buf.slice().order(), expected);
+    }
+
+    static void ckLongBuffer() {
+        long[] array = new long[LENGTH];
+        LongBuffer buf = LongBuffer.wrap(array);
+        ck(buf.order(), nord);
+        ckLongBuffer(buf, nord);
+
+        buf = LongBuffer.wrap(array, LENGTH/2, LENGTH/2);
+        ck(buf.order(), nord);
+        ckLongBuffer(buf, nord);
+
+        buf = LongBuffer.allocate(LENGTH);
+        ck(buf.order(), nord);
+        ckLongBuffer(buf, nord);
+
+        ckLongBuffer(ByteBuffer.allocate(LENGTH).asLongBuffer(), be);
+        ckLongBuffer(ByteBuffer.allocateDirect(LENGTH).asLongBuffer(), be);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/nio/Buffer/OrderShort.java	Wed Jul 15 10:43:07 2015 -0700
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* Type-specific source code for unit test
+ *
+ * Regenerate the OrderX classes via genOrder.sh whenever this file changes.
+ * We check in the generated source files so that the test tree can be used
+ * independently of the rest of the source tree.
+ */
+
+// -- This file was mechanically generated: Do not edit! -- //
+
+import java.nio.*;
+
+public class OrderShort extends Order {
+    private static void ckShortBuffer(ShortBuffer buf, ByteOrder expected) {
+        ck(buf.asReadOnlyBuffer().order(), expected);
+        ck(buf.duplicate().order(), expected);
+        ck(buf.slice().order(), expected);
+    }
+
+    static void ckShortBuffer() {
+        short[] array = new short[LENGTH];
+        ShortBuffer buf = ShortBuffer.wrap(array);
+        ck(buf.order(), nord);
+        ckShortBuffer(buf, nord);
+
+        buf = ShortBuffer.wrap(array, LENGTH/2, LENGTH/2);
+        ck(buf.order(), nord);
+        ckShortBuffer(buf, nord);
+
+        buf = ShortBuffer.allocate(LENGTH);
+        ck(buf.order(), nord);
+        ckShortBuffer(buf, nord);
+
+        ckShortBuffer(ByteBuffer.allocate(LENGTH).asShortBuffer(), be);
+        ckShortBuffer(ByteBuffer.allocateDirect(LENGTH).asShortBuffer(), be);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/nio/Buffer/genOrder.sh	Wed Jul 15 10:43:07 2015 -0700
@@ -0,0 +1,39 @@
+#! /bin/sh
+
+#
+# Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+javac -d . ../../../../make/src/classes/build/tools/spp/Spp.java > Spp.java
+
+gen() {
+    java  build.tools.spp.Spp -K$1 -Dtype=$1 -DType=$2 -DFulltype=$3<Order-X.java.template >Order$2.java
+}
+
+gen char Char Character
+gen short Short Short
+gen int Int Integer
+gen long Long Long
+gen float Float Float
+gen double Double Double
+
+rm -rf build