On 9/25/06, Denis Kishenko <[EMAIL PROTECTED]> 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) <[EMAIL PROTECTED]>:
> [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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--
--
Ilya Okomin
Intel Middleware Products Division

Reply via email to