On Tue, 6 Feb 2024 16:17:21 GMT, Claes Redestad <redes...@openjdk.org> wrote:

> Adding a fast-path for ASCII-only modified UTF-8 strings deserialied via 
> Data- and ObjectInputStream
> 
> Testing: tier1-3

src/java.base/share/classes/java/io/DataInputStream.java line 585:

> 583:         DataInputStream dis = null;
> 584:         if (in instanceof DataInputStream) {
> 585:             dis = (DataInputStream)in;

I guess that not making use of `instanceof` pattern matching is to enable 
backporting before JDK 16?

src/java.base/share/classes/java/io/DataInputStream.java line 604:

> 602:                 // For ASCII ISO-8859-1 is equivalent to UTF-8, while 
> avoiding a redundant
> 603:                 // scan
> 604:                 return new String(bytearr, 0, utflen, 
> StandardCharsets.ISO_8859_1);

Not sure this is correct.
If `bytearr` contains some `(byte)0`, that is, if `in` is malformed, this 
doesn't throw `UTFDataFormatException`, but it should: modified UTF-8 cannot 
contain zeros.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/17734#discussion_r1489261534
PR Review Comment: https://git.openjdk.org/jdk/pull/17734#discussion_r1489261783

Reply via email to