You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@harmony.apache.org by Denis Kishenko <dk...@gmail.com> on 2006/09/25 13:57:57 UTC

Re: [jira] Created: (HARMONY-1538) [classlib][awt] Successor of CubicCurve2D throws NPE in contains() if getBounds2D() returns null

Hi all

I think this is non-bug difference.

If successor of CubicCurve2D returns null instead of bounds then
Harmony throws NPE in contains() method while RI doesn't. It seems
like RI doesn't use getBounds2D() to implement contains() method while
Harmony does.

I see three possibilities
1. Exclude using of getBounds2D() from contains(). In this case
algorithm efficiency will slow down because it's part of optimization.
2. Add at contains() method an additional bounds calculation. In this
case we will get strange code duplication.
3. Stay as non-bug difference. It's very strange situation if shape
returns null bounds but such shapes are drawn well (run the test).

Comments?


2006/9/22, Denis Kishenko (JIRA) <ji...@apache.org>:
> [classlib][awt] Successor of CubicCurve2D throws NPE in contains() if getBounds2D() returns null
> -------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-1538
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1538
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Denis Kishenko
>
>
> If successor of CubicCurve2D returns null instead of bounds then Harmony throws NPE while RI doesn't. Harmony use shape bounds getBounds2D() to implement contains() and intersects() methods but It seems like RI doesn't use bounds for this.
>
> ============== Test.java =================
>
> import java.awt.Frame;
> import java.awt.Graphics;
> import java.awt.Graphics2D;
> import java.awt.geom.*;
>
> public class Test {
>    static public void main(String[] args) {
>           final CubicCurve2DImpl obj = new CubicCurve2DImpl(100, 100, 200, 200, 200, 100, 100, 200);
>
>           Frame f = new Frame("Test") {
>               public void paint(Graphics g) {
>                   ((Graphics2D)g).draw(obj);
>               }
>           };
>           f.setSize(600, 400);
>           f.show();
>
>          System.out.println("obj.contains="+obj.contains(0, 0));
>    }
> }
>
> class CubicCurve2DImpl extends java.awt.geom.CubicCurve2D.Double {
>                public CubicCurve2DImpl(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) {
>                        super(x1, y1, x2, y2, x3, y3, x4, y4);
>                }
>
>                public Rectangle2D getBounds2D() {
>                        return null;
>                }
>        }
>
> ========= RI Output =========
> obj.contains=false
>
> ======== Harmony output =====
> java.lang.NullPointerException
>    at org.apache.harmony.awt.gl.Crossing.crossShape(Crossing.java:506)
>    at java.awt.geom.CubicCurve2D.contains(CubicCurve2D.java:537)
>
>
> --
> This message is automatically generated by JIRA.
> -
> If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
> -
> For more information on JIRA, see: http://www.atlassian.com/software/jira
>
>
>


-- 
Denis M. Kishenko
Intel Middleware Products Division

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [jira] Created: (HARMONY-1538) [classlib][awt] Successor of CubicCurve2D throws NPE in contains() if getBounds2D() returns null

Posted by Denis Kishenko <dk...@gmail.com>.
OK, I will ask committers to change bug status to non-bug.

2006/9/26, Ilya Okomin <il...@gmail.com>:
> On 9/26/06, Ilya Okomin <il...@gmail.com> wrote:
> >
> >
> >
> > On 9/26/06, Denis Kishenko <dk...@gmail.com> wrote:
> > >
> > > Ilya, so do you vote for non-bug status?
> > >
> > > You are right that Shape doesn't follow spec if getBounds2D returns
> > > null - it means Shape implementation is invalid. But Harmony should
> > > follow RI (if it's possible) even if paramters are invalid. In this
> > > case we can follow RI esealy as you suggested to add null check.
> >
> >
> > For this case I vote for "non-bug" status. Suggested CubicCurve2DImpl in
> > the test sample is invalid implementation of the CubicCurve class.
> >
>
> Pardon, implementation of the CubicCurve2D class :)
>
>  Thanks,
> > Ilya.
> >
> > 2006/9/26, Ilya Okomin <il...@gmail.com>:
> > > > I suggested to return false because spec says for Shape.getBounds2D()
> > > > method:
> > > > "Returns a high precision and more accurate bounding box of the Shape
> > > than
> > > > the getBounds method." and "Shape lies entirely within the indicated
> > > > Rectangle2D.". Method CubicCurve2D.contains() checks if specified
> > > coordinate
> > > > is inside the boundary of the shape. If point inside the shape it
> > > should be
> > > > inside the bounding box of this shape.
> > > > According to this, if the bounding box of the CubicCurve2D shape is
> > > null or
> > > > empty then there is not exist any point to be inside these bounds,
> > > hence
> > > > contains() just should return false.
> > > >
> > > > Regards,
> > > > Ilya.
> > > >
> > > >
> > > > On 9/26/06, Denis Kishenko < dkishenko@gmail.com> wrote:
> > > > >
> > > > > 2006/9/25, Ilya Okomin <il...@gmail.com>:
> > > > > > To follow RI I would suggest to add check (if the bounds2D is
> > > null) to
> > > > > the
> > > > > > contains() method, in this case just to return false.
> > > > > Yep, to follow RI we can check if the bounds2D is null but why you
> > > > > suggest return false? I think in this case we have to execute
> > > > > contains() but w/o optimization. It's the fourth possibility.
> > > > >
> > > > >
> > > ---------------------------------------------------------------------
> > > > > Terms of use : http://incubator.apache.org/harmony/mailing.html
> > > > > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> > > > > For additional commands, e-mail:
> > > harmony-dev-help@incubator.apache.org
> > > > >
> > > > >
> > > >
> > > >
> > > > --
> > > > --
> > > > Ilya Okomin
> > > > Intel Middleware Products Division
> > > >
> > > >
> > >
> > >
> > > --
> > > Denis M. Kishenko
> > > Intel Middleware Products Division
> > >
> > > ---------------------------------------------------------------------
> > > Terms of use : http://incubator.apache.org/harmony/mailing.html
> > > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> > > For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> > >
> > >
> >
> >
> > --
> > --
> > Ilya Okomin
> > Intel Middleware Products Division
> >
>
>
>
> --
> --
> Ilya Okomin
> Intel Middleware Products Division
>
>


-- 
Denis M. Kishenko
Intel Middleware Products Division

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [jira] Created: (HARMONY-1538) [classlib][awt] Successor of CubicCurve2D throws NPE in contains() if getBounds2D() returns null

Posted by Ilya Okomin <il...@gmail.com>.
On 9/26/06, Ilya Okomin <il...@gmail.com> wrote:
>
>
>
> On 9/26/06, Denis Kishenko <dk...@gmail.com> wrote:
> >
> > Ilya, so do you vote for non-bug status?
> >
> > You are right that Shape doesn't follow spec if getBounds2D returns
> > null - it means Shape implementation is invalid. But Harmony should
> > follow RI (if it's possible) even if paramters are invalid. In this
> > case we can follow RI esealy as you suggested to add null check.
>
>
> For this case I vote for "non-bug" status. Suggested CubicCurve2DImpl in
> the test sample is invalid implementation of the CubicCurve class.
>

Pardon, implementation of the CubicCurve2D class :)

 Thanks,
> Ilya.
>
> 2006/9/26, Ilya Okomin <il...@gmail.com>:
> > > I suggested to return false because spec says for Shape.getBounds2D()
> > > method:
> > > "Returns a high precision and more accurate bounding box of the Shape
> > than
> > > the getBounds method." and "Shape lies entirely within the indicated
> > > Rectangle2D.". Method CubicCurve2D.contains() checks if specified
> > coordinate
> > > is inside the boundary of the shape. If point inside the shape it
> > should be
> > > inside the bounding box of this shape.
> > > According to this, if the bounding box of the CubicCurve2D shape is
> > null or
> > > empty then there is not exist any point to be inside these bounds,
> > hence
> > > contains() just should return false.
> > >
> > > Regards,
> > > Ilya.
> > >
> > >
> > > On 9/26/06, Denis Kishenko < dkishenko@gmail.com> wrote:
> > > >
> > > > 2006/9/25, Ilya Okomin <il...@gmail.com>:
> > > > > To follow RI I would suggest to add check (if the bounds2D is
> > null) to
> > > > the
> > > > > contains() method, in this case just to return false.
> > > > Yep, to follow RI we can check if the bounds2D is null but why you
> > > > suggest return false? I think in this case we have to execute
> > > > contains() but w/o optimization. It's the fourth possibility.
> > > >
> > > >
> > ---------------------------------------------------------------------
> > > > Terms of use : http://incubator.apache.org/harmony/mailing.html
> > > > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> > > > For additional commands, e-mail:
> > harmony-dev-help@incubator.apache.org
> > > >
> > > >
> > >
> > >
> > > --
> > > --
> > > Ilya Okomin
> > > Intel Middleware Products Division
> > >
> > >
> >
> >
> > --
> > Denis M. Kishenko
> > Intel Middleware Products Division
> >
> > ---------------------------------------------------------------------
> > Terms of use : http://incubator.apache.org/harmony/mailing.html
> > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> > For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> >
> >
>
>
> --
> --
> Ilya Okomin
> Intel Middleware Products Division
>



-- 
--
Ilya Okomin
Intel Middleware Products Division

Re: [jira] Created: (HARMONY-1538) [classlib][awt] Successor of CubicCurve2D throws NPE in contains() if getBounds2D() returns null

Posted by Ilya Okomin <il...@gmail.com>.
On 9/26/06, Denis Kishenko <dk...@gmail.com> wrote:
>
> Ilya, so do you vote for non-bug status?
>
> You are right that Shape doesn't follow spec if getBounds2D returns
> null - it means Shape implementation is invalid. But Harmony should
> follow RI (if it's possible) even if paramters are invalid. In this
> case we can follow RI esealy as you suggested to add null check.


For this case I vote for "non-bug" status. Suggested CubicCurve2DImpl in the
test sample is invalid implementation of the CubicCurve class.

Thanks,
Ilya.

2006/9/26, Ilya Okomin <il...@gmail.com>:
> > I suggested to return false because spec says for Shape.getBounds2D()
> > method:
> > "Returns a high precision and more accurate bounding box of the Shape
> than
> > the getBounds method." and "Shape lies entirely within the indicated
> > Rectangle2D.". Method CubicCurve2D.contains() checks if specified
> coordinate
> > is inside the boundary of the shape. If point inside the shape it should
> be
> > inside the bounding box of this shape.
> > According to this, if the bounding box of the CubicCurve2D shape is null
> or
> > empty then there is not exist any point to be inside these bounds, hence
> > contains() just should return false.
> >
> > Regards,
> > Ilya.
> >
> >
> > On 9/26/06, Denis Kishenko <dk...@gmail.com> wrote:
> > >
> > > 2006/9/25, Ilya Okomin <il...@gmail.com>:
> > > > To follow RI I would suggest to add check (if the bounds2D is null)
> to
> > > the
> > > > contains() method, in this case just to return false.
> > > Yep, to follow RI we can check if the bounds2D is null but why you
> > > suggest return false? I think in this case we have to execute
> > > contains() but w/o optimization. It's the fourth possibility.
> > >
> > > ---------------------------------------------------------------------
> > > Terms of use : http://incubator.apache.org/harmony/mailing.html
> > > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> > > For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> > >
> > >
> >
> >
> > --
> > --
> > Ilya Okomin
> > Intel Middleware Products Division
> >
> >
>
>
> --
> Denis M. Kishenko
> Intel Middleware Products Division
>
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>
>


-- 
--
Ilya Okomin
Intel Middleware Products Division

Re: [jira] Created: (HARMONY-1538) [classlib][awt] Successor of CubicCurve2D throws NPE in contains() if getBounds2D() returns null

Posted by Denis Kishenko <dk...@gmail.com>.
Ilya, so do you vote for non-bug status?

You are right that Shape doesn't follow spec if getBounds2D returns
null - it means Shape implementation is invalid. But Harmony should
follow RI (if it's possible) even if paramters are invalid. In this
case we can follow RI esealy as you suggested to add null check.

2006/9/26, Ilya Okomin <il...@gmail.com>:
> I suggested to return false because spec says for Shape.getBounds2D()
> method:
> "Returns a high precision and more accurate bounding box of the Shape than
> the getBounds method." and "Shape lies entirely within the indicated
> Rectangle2D.". Method CubicCurve2D.contains() checks if specified coordinate
> is inside the boundary of the shape. If point inside the shape it should be
> inside the bounding box of this shape.
> According to this, if the bounding box of the CubicCurve2D shape is null or
> empty then there is not exist any point to be inside these bounds, hence
> contains() just should return false.
>
> Regards,
> Ilya.
>
>
> On 9/26/06, Denis Kishenko <dk...@gmail.com> wrote:
> >
> > 2006/9/25, Ilya Okomin <il...@gmail.com>:
> > > To follow RI I would suggest to add check (if the bounds2D is null) to
> > the
> > > contains() method, in this case just to return false.
> > Yep, to follow RI we can check if the bounds2D is null but why you
> > suggest return false? I think in this case we have to execute
> > contains() but w/o optimization. It's the fourth possibility.
> >
> > ---------------------------------------------------------------------
> > Terms of use : http://incubator.apache.org/harmony/mailing.html
> > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> > For additional commands, e-mail: harmony-dev-help@incubator.apache.org
> >
> >
>
>
> --
> --
> Ilya Okomin
> Intel Middleware Products Division
>
>


-- 
Denis M. Kishenko
Intel Middleware Products Division

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [jira] Created: (HARMONY-1538) [classlib][awt] Successor of CubicCurve2D throws NPE in contains() if getBounds2D() returns null

Posted by Ilya Okomin <il...@gmail.com>.
I suggested to return false because spec says for Shape.getBounds2D()
method:
"Returns a high precision and more accurate bounding box of the Shape than
the getBounds method." and "Shape lies entirely within the indicated
Rectangle2D.". Method CubicCurve2D.contains() checks if specified coordinate
is inside the boundary of the shape. If point inside the shape it should be
inside the bounding box of this shape.
According to this, if the bounding box of the CubicCurve2D shape is null or
empty then there is not exist any point to be inside these bounds, hence
contains() just should return false.

Regards,
Ilya.


On 9/26/06, Denis Kishenko <dk...@gmail.com> wrote:
>
> 2006/9/25, Ilya Okomin <il...@gmail.com>:
> > To follow RI I would suggest to add check (if the bounds2D is null) to
> the
> > contains() method, in this case just to return false.
> Yep, to follow RI we can check if the bounds2D is null but why you
> suggest return false? I think in this case we have to execute
> contains() but w/o optimization. It's the fourth possibility.
>
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>
>


-- 
--
Ilya Okomin
Intel Middleware Products Division

Re: [jira] Created: (HARMONY-1538) [classlib][awt] Successor of CubicCurve2D throws NPE in contains() if getBounds2D() returns null

Posted by Denis Kishenko <dk...@gmail.com>.
2006/9/25, Ilya Okomin <il...@gmail.com>:
> To follow RI I would suggest to add check (if the bounds2D is null) to the
> contains() method, in this case just to return false.
Yep, to follow RI we can check if the bounds2D is null but why you
suggest return false? I think in this case we have to execute
contains() but w/o optimization. It's the fourth possibility.

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [jira] Created: (HARMONY-1538) [classlib][awt] Successor of CubicCurve2D throws NPE in contains() if getBounds2D() returns null

Posted by Ilya Okomin <il...@gmail.com>.
On 9/25/06, Denis Kishenko <dk...@gmail.com> wrote:
>
> Hi all
>
> I think this is non-bug difference.
>
> If successor of CubicCurve2D returns null instead of bounds then
> Harmony throws NPE in contains() method while RI doesn't. It seems
> like RI doesn't use getBounds2D() to implement contains() method while
> Harmony does.
>
> I see three possibilities
> 1. Exclude using of getBounds2D() from contains(). In this case
> algorithm efficiency will slow down because it's part of optimization.
> 2. Add at contains() method an additional bounds calculation. In this
> case we will get strange code duplication.
> 3. Stay as non-bug difference. It's very strange situation if shape
> returns null bounds but such shapes are drawn well (run the test).
>
> Comments?


To follow RI I would suggest to add check (if the bounds2D is null) to the
contains() method, in this case just to return false.

Regards, Ilya.

2006/9/22, Denis Kishenko (JIRA) <ji...@apache.org>:
> > [classlib][awt] Successor of CubicCurve2D throws NPE in contains() if
> getBounds2D() returns null
> >
> -------------------------------------------------------------------------------------------------
> >
> >                 Key: HARMONY-1538
> >                 URL: http://issues.apache.org/jira/browse/HARMONY-1538
> >             Project: Harmony
> >          Issue Type: Bug
> >          Components: Classlib
> >            Reporter: Denis Kishenko
> >
> >
> > If successor of CubicCurve2D returns null instead of bounds then Harmony
> throws NPE while RI doesn't. Harmony use shape bounds getBounds2D() to
> implement contains() and intersects() methods but It seems like RI doesn't
> use bounds for this.
> >
> > ============== Test.java =================
> >
> > import java.awt.Frame;
> > import java.awt.Graphics;
> > import java.awt.Graphics2D;
> > import java.awt.geom.*;
> >
> > public class Test {
> >    static public void main(String[] args) {
> >           final CubicCurve2DImpl obj = new CubicCurve2DImpl(100, 100,
> 200, 200, 200, 100, 100, 200);
> >
> >           Frame f = new Frame("Test") {
> >               public void paint(Graphics g) {
> >                   ((Graphics2D)g).draw(obj);
> >               }
> >           };
> >           f.setSize(600, 400);
> >           f.show();
> >
> >          System.out.println("obj.contains="+obj.contains(0, 0));
> >    }
> > }
> >
> > class CubicCurve2DImpl extends java.awt.geom.CubicCurve2D.Double {
> >                public CubicCurve2DImpl(double x1, double y1, double x2,
> double y2, double x3, double y3, double x4, double y4) {
> >                        super(x1, y1, x2, y2, x3, y3, x4, y4);
> >                }
> >
> >                public Rectangle2D getBounds2D() {
> >                        return null;
> >                }
> >        }
> >
> > ========= RI Output =========
> > obj.contains=false
> >
> > ======== Harmony output =====
> > java.lang.NullPointerException
> >    at org.apache.harmony.awt.gl.Crossing.crossShape(Crossing.java:506)
> >    at java.awt.geom.CubicCurve2D.contains(CubicCurve2D.java:537)
> >
> >
> > --
> > This message is automatically generated by JIRA.
> > -
> > If you think it was sent incorrectly contact one of the administrators:
> http://issues.apache.org/jira/secure/Administrators.jspa
> > -
> > For more information on JIRA, see:
> http://www.atlassian.com/software/jira
> >
> >
> >
>
>
> --
> Denis M. Kishenko
> Intel Middleware Products Division
>
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>
>


-- 
--
Ilya Okomin
Intel Middleware Products Division