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
src/java.base/share/classes/java/nio
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2023, 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
|
||||
@ -215,18 +215,14 @@ class ByteBufferAs$Type$Buffer$RW$$BO$ // package-private
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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…
x
Reference in New Issue
Block a user