mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
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:
parent
85e3974470
commit
50e31e06d7
2 changed files with 17 additions and 25 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue