8266320: (bf) ReadOnlyBufferException in heap buffer put(String,int,int) should not be conditional

Reviewed-by: alanb, bpb
This commit is contained in:
Philippe Marschall 2021-05-03 17:28:46 +00:00 committed by Brian Burkhalter
parent ff65920cd1
commit 45760d4baf

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2021, 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
@ -272,11 +272,10 @@ class Heap$Type$Buffer$RW$
#if[char]
public $Type$Buffer put(String src, int start, int end) {
#if[rw]
checkScope();
int length = end - start;
Objects.checkFromIndexSize(start, length, src.length());
if (isReadOnly())
throw new ReadOnlyBufferException();
int pos = position();
int lim = limit();
int rem = (pos <= lim) ? lim - pos : 0;
@ -285,6 +284,9 @@ class Heap$Type$Buffer$RW$
src.getChars(start, end, hb, ix(pos));
position(pos + length);
return this;
#else[rw]
throw new ReadOnlyBufferException();
#end[rw]
}
#end[char]