Skip to content

Commit 45760d4

Browse files
marschallBrian Burkhalter
authored and
Brian Burkhalter
committed
8266320: (bf) ReadOnlyBufferException in heap buffer put(String,int,int) should not be conditional
Reviewed-by: alanb, bpb
1 parent ff65920 commit 45760d4

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/java.base/share/classes/java/nio/Heap-X-Buffer.java.template

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -272,11 +272,10 @@ class Heap$Type$Buffer$RW$
272272
#if[char]
273273

274274
public $Type$Buffer put(String src, int start, int end) {
275+
#if[rw]
275276
checkScope();
276277
int length = end - start;
277278
Objects.checkFromIndexSize(start, length, src.length());
278-
if (isReadOnly())
279-
throw new ReadOnlyBufferException();
280279
int pos = position();
281280
int lim = limit();
282281
int rem = (pos <= lim) ? lim - pos : 0;
@@ -285,6 +284,9 @@ class Heap$Type$Buffer$RW$
285284
src.getChars(start, end, hb, ix(pos));
286285
position(pos + length);
287286
return this;
287+
#else[rw]
288+
throw new ReadOnlyBufferException();
289+
#end[rw]
288290
}
289291

290292
#end[char]

0 commit comments

Comments
 (0)