8266320: (bf) ReadOnlyBufferException in heap buffer put(String,int,i… · openjdk/jdk@45760d4 (original) (raw)
File tree
1 file changed
lines changed
1 file changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
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. | |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 | 4 | * |
5 | 5 | * This code is free software; you can redistribute it and/or modify it |
@@ -272,11 +272,10 @@ class Heap$Type$Buffer$RW$ | ||
272 | 272 | #if[char] |
273 | 273 | |
274 | 274 | public TypeTypeTypeBuffer put(String src, int start, int end) { |
275 | +#if[rw] | |
275 | 276 | checkScope(); |
276 | 277 | int length = end - start; |
277 | 278 | Objects.checkFromIndexSize(start, length, src.length()); |
278 | - if (isReadOnly()) | |
279 | - throw new ReadOnlyBufferException(); | |
280 | 279 | int pos = position(); |
281 | 280 | int lim = limit(); |
282 | 281 | int rem = (pos <= lim) ? lim - pos : 0; |
@@ -285,6 +284,9 @@ class Heap$Type$Buffer$RW$ | ||
285 | 284 | src.getChars(start, end, hb, ix(pos)); |
286 | 285 | position(pos + length); |
287 | 286 | return this; |
287 | +#else[rw] | |
288 | + throw new ReadOnlyBufferException(); | |
289 | +#end[rw] | |
288 | 290 | } |
289 | 291 | |
290 | 292 | #end[char] |