JDK-8130400 : Test java/awt/image/DrawImage/IncorrectClipXorModeSurface2Surface.java fails with ClassCastException
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 8u60,9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: solaris
  • CPU: generic
  • Submitted: 2015-07-03
  • Updated: 2018-05-14
  • Resolved: 2015-08-04
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 b78Fixed
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Description
Test name(s): java/awt/image/DrawImage/IncorrectClipXorModeSurface2Surface.java 

JDK tested: 9b70
OS tested: Windows , Solaris 11 
Is it a regression? NO 
Is it platform specific? Yes( test passes in windows) 
The is failure reproduced: always 
            
General description: 

----------System.out:(0/0)----------
----------System.err:(21/1470)----------
java.lang.ClassCastException: sun.java2d.loops.XORComposite cannot be cast to java.awt.AlphaComposite
	at sun.java2d.xr.XRDrawImage.renderImageXform(XRDrawImage.java:49)
	at sun.java2d.pipe.DrawImage.transformImage(DrawImage.java:264)
	at sun.java2d.pipe.DrawImage.scaleImage(DrawImage.java:124)
	at sun.java2d.pipe.DrawImage.scaleImage(DrawImage.java:1050)
	at sun.java2d.pipe.ValidatePipe.scaleImage(ValidatePipe.java:207)
	at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3274)
	at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3214)
	at IncorrectClipXorModeSurface2Surface.draw(IncorrectClipXorModeSurface2Surface.java:136)
	at IncorrectClipXorModeSurface2Surface.main(IncorrectClipXorModeSurface2Surface.java:112)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:502)
	at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:92)
	at java.lang.Thread.run(Thread.java:745)

JavaTest Message: Test threw exception: java.lang.ClassCastException: sun.java2d.loops.XORComposite cannot be cast to java.awt.AlphaComposite
JavaTest Message: shutting down test

STATUS:Failed.`main' threw exception: java.lang.ClassCastException: sun.java2d.loops.XORComposite cannot be cast to java.awt.AlphaComposite
Comments
Test fails with same error for jdk 1.8.0_60 b27. Please check if backport is needed.
16-09-2015

> Test fails with same error for 8u66b10 also That is no surprise. This bug is not a regression.
24-08-2015

Test fails with same error for 8u66b10 also . Please check if backport is needed.
24-08-2015

The problem is caused due to this part of code in jdk/src/java.desktop/unix/classes/sun/java2d/xr/XRDrawImage.java :- public class XRDrawImage extends DrawImage { protected void renderImageXform(SunGraphics2D sg, Image img, AffineTransform tx, int interpType, int sx1, int sy1, int sx2, int sy2, Color bgColor) { SurfaceData dstData = sg.surfaceData; SurfaceData srcData = dstData.getSourceSurfaceData(img, SunGraphics2D.TRANSFORM_GENERIC, sg.imageComp, bgColor); int compRule = ((AlphaComposite) sg.composite).getRule(); float extraAlpha = ((AlphaComposite) sg.composite).getAlpha(); -------------------------------------------------------------------------------------------- } } Where the Type Cast is being done by AlphaComposite but sinceTest is setting XORMode so we can put a check before typecasting that if it is an instance of AlphaComposite as below :- public class XRDrawImage extends DrawImage { protected void renderImageXform(SunGraphics2D sg, Image img, AffineTransform tx, int interpType, int sx1, int sy1, int sx2, int sy2, Color bgColor) { SurfaceData dstData = sg.surfaceData; SurfaceData srcData = dstData.getSourceSurfaceData(img, SunGraphics2D.TRANSFORM_GENERIC, sg.imageComp, bgColor); if ( sg.composite instanceof AlphaComposite) { //Adding this check before typecasting int compRule = ((AlphaComposite) sg.composite).getRule(); float extraAlpha = ((AlphaComposite) sg.composite).getAlpha(); ------------------------------------------- } }
03-07-2015

This test is newly introduced as part of fix for JDK-8061831 in 9b70
03-07-2015