Project: SWT
Bug 242484 org.eclipse.swt.graphics.Rectangle.contains(int, int) returns incorrect results
Reported: 2008-07-29 19:53:30 | Status: resolved fixed

The implementation of Rectangle.contains(int, int) does not account for possible overflow or underflow and can return incorrect results if it occurs. Here is an example that shows SWT's Rectangle.contains(int, int) incorrectly returning true. It also shows AWT's and draw2d's implementations returning the correct value (false): public class Rectmangler { public static void main(String[] args) { int x = 800; int y = Integer.MAX_VALUE; org.eclipse.swt.graphics.Rectangle swt = new org.eclipse.swt.graphics.Rectangle(0, -1024, 1280, 1024); System.out.printf("SWT says %s\n", swt.contains(x, y)); java.awt.Rectangle awt = new java.awt.Rectangle(0, -1024, 1280, 1024); System.out.printf("AWT says %s\n", awt.contains(x, y)); org.eclipse.draw2d.geometry.Rectangle draw2d = new org.eclipse.draw2d.geometry.Rectangle(0, -1024, 1280, 1024); System.out.printf("draw2d says %s\n", draw2d.contains(x, y)); } } When I run this I get: SWT says true AWT says false draw2d says false

Files changed in fix:
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Rectangle.java