Skip to content
Permalink
Browse files
8257212: (bf spec) Clarify byte order of the buffer returned by CharB…
…uffer.subsequence(int,int)

Reviewed-by: chegar, bpb, alanb
  • Loading branch information
c-cleary authored and ChrisHegarty committed Jan 15, 2021
1 parent 0ec2c96 commit 707bce080d0eb62f5a85ea3b230d36dbb0ab94b0
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2021, 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
@@ -1835,9 +1835,10 @@ public abstract class $Type$Buffer
* content of this buffer is mutable then modifications to one buffer will
* cause the other to be modified. The new buffer's capacity will be that
* of this buffer, its position will be
* {@code position()} + {@code start}, and its limit will be
* {@code position()} + {@code end}. The new buffer will be
* direct if, and only if, this buffer is direct, and it will be read-only
* {@code position()} + {@code start}, its limit will be
* {@code position()} + {@code end}, and its byte order
* will be identical to that 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>
*
* @param start
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2021, 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
@@ -37,6 +37,10 @@ public class Order$Type$ extends Order {
ck(buf.asReadOnlyBuffer().order(), expected);
ck(buf.duplicate().order(), expected);
ck(buf.slice().order(), expected);
#if[char]
ck(buf.subSequence(buf.position(), buf.remaining()).order(), expected);
ck(buf.subSequence(buf.position(), buf.position()).order(), expected);
#end[char]
}

static void ck$Type$Buffer() {
@@ -52,5 +56,27 @@ public class Order$Type$ extends Order {
buf = $Type$Buffer.allocate(LENGTH);
ck(buf.order(), nord);
ck$Type$Buffer(buf, nord);
#if[char]
buf = $Type$Buffer.wrap("abcdefghijk");
ck(buf.order(), nord);
ck$Type$Buffer(buf, nord);

buf = $Type$Buffer.wrap("abcdefghijk", 0, 5);
ck(buf.order(), nord);
ck$Type$Buffer(buf, nord);

buf = $Type$Buffer.wrap(array).subSequence(0, LENGTH);
ck(buf.order(), nord);
ck$Type$Buffer(buf, nord);

buf = ByteBuffer.wrap(new byte[LENGTH]).as$Type$Buffer();
ck(buf.order(), be);
ck$Type$Buffer(buf, be);

buf = ByteBuffer.wrap(new byte[LENGTH]).order(le).as$Type$Buffer();
ck(buf.order(), le);
ck$Type$Buffer(buf, le);
#end[char]
}
}

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2021, 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
@@ -37,6 +37,10 @@ private static void ckCharBuffer(CharBuffer buf, ByteOrder expected) {
ck(buf.asReadOnlyBuffer().order(), expected);
ck(buf.duplicate().order(), expected);
ck(buf.slice().order(), expected);

ck(buf.subSequence(buf.position(), buf.remaining()).order(), expected);
ck(buf.subSequence(buf.position(), buf.position()).order(), expected);

}

static void ckCharBuffer() {
@@ -52,5 +56,27 @@ static void ckCharBuffer() {
buf = CharBuffer.allocate(LENGTH);
ck(buf.order(), nord);
ckCharBuffer(buf, nord);

buf = CharBuffer.wrap("abcdefghijk");
ck(buf.order(), nord);
ckCharBuffer(buf, nord);

buf = CharBuffer.wrap("abcdefghijk", 0, 5);
ck(buf.order(), nord);
ckCharBuffer(buf, nord);

buf = CharBuffer.wrap(array).subSequence(0, LENGTH);
ck(buf.order(), nord);
ckCharBuffer(buf, nord);

buf = ByteBuffer.wrap(new byte[LENGTH]).asCharBuffer();
ck(buf.order(), be);
ckCharBuffer(buf, be);

buf = ByteBuffer.wrap(new byte[LENGTH]).order(le).asCharBuffer();
ck(buf.order(), le);
ckCharBuffer(buf, le);

}
}

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2021, 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
@@ -37,6 +37,10 @@ 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() {
@@ -52,5 +56,27 @@ static void ckDoubleBuffer() {
buf = DoubleBuffer.allocate(LENGTH);
ck(buf.order(), nord);
ckDoubleBuffer(buf, nord);





















}
}

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2021, 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
@@ -37,6 +37,10 @@ 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() {
@@ -52,5 +56,27 @@ static void ckFloatBuffer() {
buf = FloatBuffer.allocate(LENGTH);
ck(buf.order(), nord);
ckFloatBuffer(buf, nord);





















}
}

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2021, 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
@@ -37,6 +37,10 @@ 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() {
@@ -52,5 +56,27 @@ static void ckIntBuffer() {
buf = IntBuffer.allocate(LENGTH);
ck(buf.order(), nord);
ckIntBuffer(buf, nord);





















}
}

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2021, 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
@@ -37,6 +37,10 @@ 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() {
@@ -52,5 +56,27 @@ static void ckLongBuffer() {
buf = LongBuffer.allocate(LENGTH);
ck(buf.order(), nord);
ckLongBuffer(buf, nord);





















}
}

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2021, 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
@@ -37,6 +37,10 @@ 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() {
@@ -52,5 +56,27 @@ static void ckShortBuffer() {
buf = ShortBuffer.allocate(LENGTH);
ck(buf.order(), nord);
ckShortBuffer(buf, nord);





















}
}

1 comment on commit 707bce0

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on 707bce0 Jan 15, 2021

Please sign in to comment.