[OpenJDK 2D-Dev] [9] RFR: JDK-7107620, , Need to round in test java/awt/print/PageFormat/PageFormatFromAttributes.java

prasanta sadhukhan prasanta.sadhukhan at oracle.com
Wed Mar 23 07:26:00 UTC 2016

Hi Phil,

Please review a simple fix for jdk9.
Bug: https://bugs.openjdk.java.net/browse/JDK-7107620
webrev: http://cr.openjdk.java.net/~psadhukhan/7107620/webrev.00/

It was seen width/height obtained by calculating via MediaSize/units is 
not same as obtained from Paper.getWIdth/getHeight().
It seems the testcase is storing the result of the calculations in "int" 
varible whereas MediaSize.getX()/getY() is "float" and units is "double" 
variable thereby resulting is loss of precision.

It was only seen in osx as osx returns a integer value for 
getWidth()/getHeight() ie 842 instead of ~841.889 maybe because it 
rounds off to nearest whereas MediaSize/units value is stored as 841 
when typecasted to int
resulting in failure.
Modified testcase to store in "double" to avoid loss of precision and 
use Math.round() to round off to nearest value before comparing these 2 
values (from MediaSize/units and getWidth/getHeight).

Tested in windows, linux, mac to be working.


More information about the 2d-dev mailing list