JDK-8147542 : Linux: ClassCastException when repainting after display resolution change
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2016-01-18
  • Updated: 2018-06-20
  • Resolved: 2016-07-25
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.
JDK 8 JDK 9
8u172Fixed 9 b131Fixed
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Relates :  
Description
OS: Ubuntu 14.04 Linux, Unity / GNOME + HiDPI display (but the issue is also reproducible on non-HiDPI display), JDK9 b101

Please run test code from JDK-8147016
1. 1x image is displayed. is it what expected (see JDK-8147557)?
2.  try to switch display resolution. No image is displayed after repaint, ClassCastException is reported:

Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: sun.awt.image.BufImgSurfaceData cannot be cast to sun.java2d.xr.XRSurfaceData
	at sun.java2d.xr.XRPMBlitLoops.cacheToTmpSurface(XRPMBlitLoops.java:145)
	at sun.java2d.xr.XrSwToPMBlit.Blit(XRPMBlitLoops.java:354)
	at sun.java2d.SurfaceDataProxy.updateSurfaceData(SurfaceDataProxy.java:498)
	at sun.java2d.SurfaceDataProxy.replaceData(SurfaceDataProxy.java:455)
	at sun.java2d.SurfaceData.getSourceSurfaceData(SurfaceData.java:233)
	at sun.java2d.pipe.DrawImage.renderImageScale(DrawImage.java:629)
	at sun.java2d.pipe.DrawImage.scaleImage(DrawImage.java:724)
	at sun.java2d.pipe.DrawImage.scaleImage(DrawImage.java:1069)
	at sun.java2d.pipe.ValidatePipe.scaleImage(ValidatePipe.java:219)
	at sun.java2d.SunGraphics2D.scaleImage(SunGraphics2D.java:3180)
	at sun.java2d.SunGraphics2D.drawHiDPIImage(SunGraphics2D.java:3166)
	at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3399)
	at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3383)
	at MultiRes.paint(MultiRes.java:50)
        ...

(please find the logs attached)


Comments
Here is the fix of the problem: http://cr.openjdk.java.net/~avu/JDK-8147542/webrev.00
22-07-2016

> It is necessary to set GDK_SCALE environment variable to 2 for HiDPI enabling thanks, it works. but it seems that in such a case the "2x" image is drawn for any display resolution, which is probably wrong behavior? or not? e.g., for OS X in case of 2-display configuration (HiDPI + non-HiDPI) we have different images when dragging from one display to another.
18-01-2016

> 1. 1x image is displayed. is it what expected (see JDK-8147557)? It is necessary to set GDK_SCALE environment variable to 2 for HiDPI enabling. See https://developer.gnome.org/gtk3/stable/gtk-x11.html
18-01-2016

The issue also affects other components, not only the image.
18-01-2016

the frame must be non-resizeable to reproduce the issue
18-01-2016