RFR: 8343039: Remove jdk.internal.misc.InternalLock and usages from java.io

Chen Liang liach at openjdk.org
Wed Nov 13 03:20:51 UTC 2024


On Tue, 12 Nov 2024 21:45:41 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

> Uses of `InternalLock` are removed and `synchronized` is reinstated.

https://github.com/openjdk/jdk/tree/5212535a276a92d96ca20bdcfccfbce956febdb1 is a baseline for before virtual threads were integrated.  Note that in this period, there are other optimizations such as lazy allocation for buffer arrays or some jfr changes, so these aren't exact matches.

src/java.base/share/classes/java/io/BufferedOutputStream.java line 88:

> 86:         }
> 87: 
> 88:         this.buf = new byte[initialSize]; // resizable if initialSize < maxSize

Same remark as for BIS.

Also this initial vs max size feature was added when virtual thread was first implemented as the internal locks.  Is this implementation detail still necessary for the virtual threads?

src/java.base/share/classes/java/io/Writer.java line 279:

> 277:     public void write(String str, int off, int len) throws IOException {
> 278:         synchronized (lock) {
> 279:             char cbuf[];

As annoying as this is, but https://bugs.openjdk.org/browse/JDK-8272626 didn't fix c-style arrays in method bodies.  Sad.

-------------

PR Review: https://git.openjdk.org/jdk/pull/22048#pullrequestreview-2431668566
PR Review Comment: https://git.openjdk.org/jdk/pull/22048#discussion_r1839327857
PR Review Comment: https://git.openjdk.org/jdk/pull/22048#discussion_r1839331137


More information about the core-libs-dev mailing list