JDK-7124520 : [macosx] re:6373505 Toolkit.getScreenResolution() != GraphicsConfiguration.getNormalizingTransform()
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 7
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: os_x
  • CPU: generic
  • Submitted: 2011-12-23
  • Updated: 2014-03-11
  • Resolved: 2012-10-19
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
7u40Fixed 8 b63Fixed
Related Reports
Relates :  
http://java.net/jira/browse/MACOSX_PORT-709 submitted 2011/11/16 by Yuri Nesterenko
Attached is a regression test to <span class=&quot;nobr&quot;><a href=&quot;http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6373505&quot;>http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6373505<sup><img class=&quot;rendericon&quot; src=&quot;/jira/images/icons/linkext7.gif&quot; height=&quot;7&quot; width=&quot;7&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/></sup></a></span> &#8211;
it's very short.
On my system toolkit reports screen resolution == 72 while default configuration of default screen device gets 85. Looks like the former one is hardcoded, isn't it?
The same test also fails on Apple JDK 6.

java/awt/GraphicsConfiguration/NormalizingTransformTest/NormalizingTransformTest.java PASSED under JDK 8 b132 on MacOS, Linux, Solaris, Windows. Closed issue as Fixed/Verified.

Testcase moved to java/awt/GraphicsConfiguration/NormalizingTransformTest/NormalizingTransformTest.java

EVALUATION The test verifies that the result of Toolkit.getScreenResolution() is consistent with GraphicsConfiguration.getNormalizingTransform(). The actual implementation of Toolkit.getScreenResolution() (see src/macosx/classes/sun/awt/CGraphicsDevice.java) is public int getScreenResolution() { // TODO: report non-72 value when HiDPI is turned on return 72; } The actual implementation of GraphicsConfiguration.getNormalizingTransform() (see src/macosx/native/sun/awt/CGraphicsDevice.m) is JNIEXPORT jdouble JNICALL Java_sun_awt_CGraphicsDevice_nativeGetXResolution (JNIEnv *env, jclass class, jint displayID) { // TODO: this is the physically correct answer, but we probably want // to use NSScreen API instead... CGSize size = CGDisplayScreenSize(displayID); CGRect rect = CGDisplayBounds(displayID); // 1 inch == 25.4 mm jfloat inches = size.width / 25.4f; jfloat dpi = rect.size.width / inches; return dpi; } Looks like it's wrong that Toolkit.getScreenResolution() returns hardcoded value and its implementation should fetch the appropriate value from the native code like we do on other platforms.

EVALUATION Author: Yuri Nesterenko Date: 16/Nov/11 10:29 AM Build: b217 closed/java/awt/GraphicsConfiguration/NormalizingTransformTest/NormalizingTransformTest.java