8306959: (bf) CharBuffer.append(CharSequence,int,int) throws BufferOverflowException where IndexOutOfBoundsException expected
Reviewed-by: alanb
This commit is contained in:
parent
eb358619df
commit
80fae514b1
@ -289,6 +289,8 @@ class Heap$Type$Buffer$RW$
|
|||||||
private $Type$Buffer appendChars(CharSequence csq, int start, int end) {
|
private $Type$Buffer appendChars(CharSequence csq, int start, int end) {
|
||||||
checkSession();
|
checkSession();
|
||||||
|
|
||||||
|
Objects.checkFromToIndex(start, end, csq.length());
|
||||||
|
|
||||||
int length = end - start;
|
int length = end - start;
|
||||||
int pos = position();
|
int pos = position();
|
||||||
int lim = limit();
|
int lim = limit();
|
||||||
|
@ -2045,6 +2045,8 @@ public abstract sealed class $Type$Buffer
|
|||||||
*/
|
*/
|
||||||
public $Type$Buffer append(CharSequence csq, int start, int end) {
|
public $Type$Buffer append(CharSequence csq, int start, int end) {
|
||||||
if (csq instanceof CharBuffer cb) {
|
if (csq instanceof CharBuffer cb) {
|
||||||
|
Objects.checkFromToIndex(start, end, csq.length());
|
||||||
|
|
||||||
//
|
//
|
||||||
// the append method throws BufferOverflowException when
|
// the append method throws BufferOverflowException when
|
||||||
// there is insufficient space in the buffer
|
// there is insufficient space in the buffer
|
||||||
|
@ -630,7 +630,7 @@ public class Basic$Type$
|
|||||||
absBulkGet(b);
|
absBulkGet(b);
|
||||||
|
|
||||||
#if[char]
|
#if[char]
|
||||||
// 8306623
|
// 8306623 and 8306959
|
||||||
String str = "in violet night walking beneath a reign of uncouth stars";
|
String str = "in violet night walking beneath a reign of uncouth stars";
|
||||||
char[] chars = str.toCharArray();
|
char[] chars = str.toCharArray();
|
||||||
int cslen = chars.length;
|
int cslen = chars.length;
|
||||||
@ -661,14 +661,29 @@ public class Basic$Type$
|
|||||||
tryCatch(cbBOE, BufferOverflowException.class, () ->
|
tryCatch(cbBOE, BufferOverflowException.class, () ->
|
||||||
cbBOE.append(csq, cslen/4, cslen/2));
|
cbBOE.append(csq, cslen/4, cslen/2));
|
||||||
|
|
||||||
|
CharBuffer cb = f.apply(7);
|
||||||
|
tryCatch(cbBOE, BufferOverflowException.class, () ->
|
||||||
|
cb.append(csq.subSequence(0, 8), 0, 8));
|
||||||
|
|
||||||
// append() should throw IndexOutOfBoundsException
|
// append() should throw IndexOutOfBoundsException
|
||||||
final CharBuffer cbIOOBE = f.apply(cslen + 1);
|
final CharBuffer cbIOOBE = f.apply(cslen + 1);
|
||||||
for (int[] bds : bounds)
|
for (int[] bds : bounds)
|
||||||
tryCatch(cbIOOBE, IndexOutOfBoundsException.class, () ->
|
tryCatch(cbIOOBE, IndexOutOfBoundsException.class, () ->
|
||||||
cbIOOBE.append(csq, bds[0], bds[1]));
|
cbIOOBE.append(csq, bds[0], bds[1]));
|
||||||
|
|
||||||
|
tryCatch(cb, IndexOutOfBoundsException.class, () ->
|
||||||
|
cb.append(csq.subSequence(0, 8), 4, 12));
|
||||||
|
|
||||||
|
// should append nothing
|
||||||
|
int rem = cb.remaining();
|
||||||
|
ck(cb, cb.append(csq, 0, 0).remaining(), rem);
|
||||||
|
|
||||||
|
// should fill the buffer
|
||||||
|
int start = (csq.length() - rem)/2;
|
||||||
|
ck(cb, cb.append(csq, start, start + rem).remaining(), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// end 8306623
|
// end 8306623 and 8306959
|
||||||
|
|
||||||
bulkPutString(b);
|
bulkPutString(b);
|
||||||
relGet(b);
|
relGet(b);
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
* @bug 4413135 4414911 4416536 4416562 4418782 4471053 4472779 4490253 4523725
|
* @bug 4413135 4414911 4416536 4416562 4418782 4471053 4472779 4490253 4523725
|
||||||
* 4526177 4463011 4660660 4661219 4663521 4782970 4804304 4938424 5029431
|
* 4526177 4463011 4660660 4661219 4663521 4782970 4804304 4938424 5029431
|
||||||
* 5071718 6231529 6221101 6234263 6535542 6591971 6593946 6795561 7190219
|
* 5071718 6231529 6221101 6234263 6535542 6591971 6593946 6795561 7190219
|
||||||
* 7199551 8065556 8149469 8230665 8237514 8306374 8306623
|
* 7199551 8065556 8149469 8230665 8237514 8306374 8306623 8306959
|
||||||
* @modules java.base/java.nio:open
|
* @modules java.base/java.nio:open
|
||||||
* java.base/jdk.internal.misc
|
* java.base/jdk.internal.misc
|
||||||
* @author Mark Reinhold
|
* @author Mark Reinhold
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -43,6 +43,9 @@ import java.util.Random;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class BasicByte
|
public class BasicByte
|
||||||
extends Basic
|
extends Basic
|
||||||
{
|
{
|
||||||
@ -641,6 +644,60 @@ public class BasicByte
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -630,7 +630,7 @@ public class BasicChar
|
|||||||
absBulkGet(b);
|
absBulkGet(b);
|
||||||
|
|
||||||
|
|
||||||
// 8306623
|
// 8306623 and 8306959
|
||||||
String str = "in violet night walking beneath a reign of uncouth stars";
|
String str = "in violet night walking beneath a reign of uncouth stars";
|
||||||
char[] chars = str.toCharArray();
|
char[] chars = str.toCharArray();
|
||||||
int cslen = chars.length;
|
int cslen = chars.length;
|
||||||
@ -661,14 +661,29 @@ public class BasicChar
|
|||||||
tryCatch(cbBOE, BufferOverflowException.class, () ->
|
tryCatch(cbBOE, BufferOverflowException.class, () ->
|
||||||
cbBOE.append(csq, cslen/4, cslen/2));
|
cbBOE.append(csq, cslen/4, cslen/2));
|
||||||
|
|
||||||
|
CharBuffer cb = f.apply(7);
|
||||||
|
tryCatch(cbBOE, BufferOverflowException.class, () ->
|
||||||
|
cb.append(csq.subSequence(0, 8), 0, 8));
|
||||||
|
|
||||||
// append() should throw IndexOutOfBoundsException
|
// append() should throw IndexOutOfBoundsException
|
||||||
final CharBuffer cbIOOBE = f.apply(cslen + 1);
|
final CharBuffer cbIOOBE = f.apply(cslen + 1);
|
||||||
for (int[] bds : bounds)
|
for (int[] bds : bounds)
|
||||||
tryCatch(cbIOOBE, IndexOutOfBoundsException.class, () ->
|
tryCatch(cbIOOBE, IndexOutOfBoundsException.class, () ->
|
||||||
cbIOOBE.append(csq, bds[0], bds[1]));
|
cbIOOBE.append(csq, bds[0], bds[1]));
|
||||||
|
|
||||||
|
tryCatch(cb, IndexOutOfBoundsException.class, () ->
|
||||||
|
cb.append(csq.subSequence(0, 8), 4, 12));
|
||||||
|
|
||||||
|
// should append nothing
|
||||||
|
int rem = cb.remaining();
|
||||||
|
ck(cb, cb.append(csq, 0, 0).remaining(), rem);
|
||||||
|
|
||||||
|
// should fill the buffer
|
||||||
|
int start = (csq.length() - rem)/2;
|
||||||
|
ck(cb, cb.append(csq, start, start + rem).remaining(), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// end 8306623
|
// end 8306623 and 8306959
|
||||||
|
|
||||||
bulkPutString(b);
|
bulkPutString(b);
|
||||||
relGet(b);
|
relGet(b);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -43,6 +43,9 @@ import java.nio.*;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class BasicDouble
|
public class BasicDouble
|
||||||
extends Basic
|
extends Basic
|
||||||
{
|
{
|
||||||
@ -641,6 +644,60 @@ public class BasicDouble
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -43,6 +43,9 @@ import java.nio.*;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class BasicFloat
|
public class BasicFloat
|
||||||
extends Basic
|
extends Basic
|
||||||
{
|
{
|
||||||
@ -641,6 +644,60 @@ public class BasicFloat
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -43,6 +43,9 @@ import java.nio.*;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class BasicInt
|
public class BasicInt
|
||||||
extends Basic
|
extends Basic
|
||||||
{
|
{
|
||||||
@ -641,6 +644,60 @@ public class BasicInt
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -43,6 +43,9 @@ import java.nio.*;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class BasicLong
|
public class BasicLong
|
||||||
extends Basic
|
extends Basic
|
||||||
{
|
{
|
||||||
@ -641,6 +644,60 @@ public class BasicLong
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -43,6 +43,9 @@ import java.nio.*;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class BasicShort
|
public class BasicShort
|
||||||
extends Basic
|
extends Basic
|
||||||
{
|
{
|
||||||
@ -641,6 +644,60 @@ public class BasicShort
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user