8219196: DataOutputStream.writeUTF may throw unexpected exceptions

Roger Riggs Roger.Riggs at oracle.com
Mon Mar 18 13:40:41 UTC 2019


Hi Brian,

On 03/15/2019 05:06 PM, Brian Burkhalter wrote:
> Updated: http://cr.openjdk.java.net/~bpb/8219196/webrev.01/ 
> <http://cr.openjdk.java.net/%7Ebpb/8219196/webrev.01/>

I'm at odds with Martin on including utflen in the loop.  (Or that's not 
what he meant).
Now it has to do two comparisons for every input byte instead of 1.

There is no need to have an early exit for input strings that are too long.
It is a very unusual case, probably never except in testing.

There might be a case for checking that  strlen <= 65535,
(even at 1 input byte per output byte it would be too large).
But even that is probably not worth the compare and branch.

>
>>> Instead of disabling the test statically, you could make it conditional
>>> on Runtime.maxMemory but the test will fail quickly anyway.
>
> For this I simply added the requirement to the jtreg tags instead.
With the fix, it will throw immediately before any allocation, so there is
no need for a restriction on memory size.
The only time that would be necessary would be running the test on a 
runtime without the fix.

The @requires >4g restriction is unnecessary.

$.02, Roger




More information about the core-libs-dev mailing list