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

Polygon.getBounds() works wrong for empty polygons

XMLWordPrintable

    • 2d
    • beta
    • sparc
    • solaris_2.5



      Name: dsC58869 Date: 12/04/98



      The method Rectangle getBounds() works wrong for empty polygons.
      In this case it is expected for the method to return null
      or an empty rectangle, but the returned rectangle is not empty.

      ==== Here is the test demonstrating the bug ====
      import java.awt.*;

      public class Test {
          public static void main (String args[]) {
      Polygon p = new Polygon();
      Rectangle r = p.getBounds();
      System.out.println(r);
      if(r == null || r.isEmpty())
      System.out.println("OKAY");
      else
      System.out.println("failed");
          }
      }
      ==== Here is the output of the test ====
      %java -fullversion
      java full version "JDK-1.2-V"
      %java Test
      java.awt.Rectangle[x=2147483647,y=2147483647,width=1,height=1]
      failed

      ======================================================================
       Justification:
      The method should work properly


      ======================================================================

            flar Jim Graham
            dsilaev Dmitri Silaev
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: