On Wed, 13 Nov 2024 02:41:05 GMT, ExE Boss <d...@openjdk.org> wrote: >> Uses of `InternalLock` are removed and `synchronized` is reinstated. > > src/java.base/share/classes/java/io/BufferedInputStream.java line 241: > >> 239: } >> 240: initialSize = size; >> 241: buf = new byte[size]; > > This should probably still retain the lazy buffer array creation: > Suggestion: > > size; > if (getClass() == BufferedInputStream.class) { > // lazily create buffer when not subclassed > buf = EMPTY; > } else { > // eagerly create buffer when subclassed > buf = new byte[size]; > }
Indeed. This and that for BufferedOutputStream are for backward compatibility with subclasses. We cannot control when subclasses access the `buf` field after the constructor call, so laziness was impossible. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/22048#discussion_r1839323249