8305442: (bf) Direct and view implementations of CharBuffer.toString(int, int) do not need to catch SIOBE

Reviewed-by: alanb, bpb
This commit is contained in:
Sergey Tsypanov 2023-04-03 16:16:05 +00:00 committed by Brian Burkhalter
parent 85e3974470
commit 50e31e06d7
2 changed files with 17 additions and 25 deletions

View file

@ -433,18 +433,14 @@ class Direct$Type$Buffer$RW$$BO$
public String toString(int start, int end) {
Objects.checkFromToIndex(start, end, limit());
try {
int len = end - start;
char[] ca = new char[len];
CharBuffer cb = CharBuffer.wrap(ca);
CharBuffer db = this.duplicate();
db.position(start);
db.limit(end);
cb.put(db);
return new String(ca);
} catch (StringIndexOutOfBoundsException x) {
throw new IndexOutOfBoundsException();
}
int len = end - start;
char[] ca = new char[len];
CharBuffer cb = CharBuffer.wrap(ca);
CharBuffer db = this.duplicate();
db.position(start);
db.limit(end);
cb.put(db);
return new String(ca);
}