Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8042103

Deserialization of empty java.awt.geom.Path2D will cause an exception

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 7, 8, 9
    • Fix Version/s: 9
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b22
    • OS:
      os_x

      Backports

        Description

        FULL PRODUCT VERSION :


        A DESCRIPTION OF THE PROBLEM :
        If a Path2D object has none path segments and its capacity is 0, then call its moveTo() method will cause an exception(java.lang.ArrayIndexOutOfBoundsException: 0).

        My application includes several Path objects and these objects need to be serialized.If one object before serialization call reset () method, and its capacity will be 0.This object is deserialized will be unavailable because it has lost the ability to increase capacity.

        I found Path2D.needRoom(...) cause this issue by check the java source code.

        Others will cause an empty Path2D object (except of deserialization):
        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);

        Please pardon me for my English.



        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        Path2D myPath1,myPath2;

        myPath1 = new Path2D.Double();
        ......
        myPath1.reset();

        ObjectOutputStream oos = new ObjectOutputStream(...);
        oos.writeObject(myPath);

        ObjectInputStream ois = new ObjectInputStream(...);
        myPath2 = (Path2D)ois.readObject();

        myPath2.moveTo(10,10); // throw java.lang.ArrayIndexOutOfBoundsException:0
        ---------- END SOURCE ----------

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                serb Sergey Bylokhov
                Reporter:
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: