Skip to content
Permalink
Browse files
8266320: (bf) ReadOnlyBufferException in heap buffer put(String,int,i…
…nt) should not be conditional

Reviewed-by: alanb, bpb
  • Loading branch information
marschall authored and Brian Burkhalter committed May 3, 2021
1 parent ff65920 commit 45760d4baf5da7537e1bae70796e869309d4aeff
Showing with 5 additions and 3 deletions.
  1. +5 −3 src/java.base/share/classes/java/nio/Heap-X-Buffer.java.template
@@ -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]

0 comments on commit 45760d4

Please sign in to comment.