[OpenJDK 2D-Dev] [9] Review Request: 8042103 Deserialization of empty java.awt.geom.Path2D will cause an exception

Jim Graham james.graham at oracle.com
Wed Jun 11 03:02:59 UTC 2014

Hi Sergey,

I wasn't watching my 2D mailbox for a while.  This makes sense.

The only other suggestion I would have is that the minimum growth should 
probably be INIT_SIZE rather than "1", but the coord growth doesn't do 
that either (it does enforce enough growth space for the current 
segment, but it doesn't enforce a minimum of INIT_SIZE).

The fix looks fine...


On 5/5/14 6:30 AM, Sergey Bylokhov wrote:
> Hi, Jim.
> On 01.05.2014 4:44, Jim Graham wrote:
>> Hi Sergey,
>> I think the bug is in the readObject routine.  It sets the initial
>> size of the arrays based on if the number of segments/coords is "< 0"
>> and it sets them to INIT_SIZE or INIT_SIZE*2 accordingly.  Those tests
>> should be "< INIT_SIZE(*2)"...
> It was my first thought, but we have an API, which allows to set
> starting value of capacity to 0.
> Copy from the bug description:
> 1.Path2D path = Path2D.Float(int rule, int initialCapacity); while
> initialCapacity is 0
> 2.Path2D path = Path2D.Double(int rule, int initialCapacity);
> 3.Path2D path = Path2D.Float(Shape s); while s is empty Path2D
> 4.Path2D path = Path2D.Float(Shape s, AffineTransform at);
> 5.Path2D path = Path2D.Double(Shape s);
> 6.Path2D path = Path2D.Double(Shape s, AffineTransform at);
> based on these I assume that empty capacity is correct value, and
> needRoom should be ready for that.
>>             ...jim
>> On 4/30/14 8:52 AM, Sergey Bylokhov wrote:
>>> Hello.
>>> Please review the fix for jdk 9.
>>> needRoom() method does not take into account that current array of types
>>> can be empty. In this case it fails to increase it.
>>> I handle this case and increase the size of the array by 1 instead of
>>> INIT_SIZE, because I assume that the user intentionally try to decrease
>>> memory usage.
>>> Bug: https://bugs.openjdk.java.net/browse/JDK-8042103
>>> Webrev can be found at:
>>> http://cr.openjdk.java.net/~serb/8042103/webrev.00

More information about the 2d-dev mailing list