8158495: CCE: sun.java2d.NullSurfaceData cannot be cast to sun.java2d.opengl.OGLSurfaceData

Reviewed-by: serb, prr
This commit is contained in:
Alexey Ushakov 2016-06-06 16:23:37 +03:00
parent ee120117f8
commit af683a251d
3 changed files with 24 additions and 2 deletions

View File

@ -26,6 +26,7 @@
package sun.java2d.opengl;
import java.awt.Composite;
import sun.java2d.InvalidPipeException;
import sun.java2d.SunGraphics2D;
import sun.java2d.loops.GraphicsPrimitive;
import sun.java2d.loops.GraphicsPrimitiveMgr;
@ -67,7 +68,14 @@ class OGLMaskFill extends BufferedMaskFill {
protected void validateContext(SunGraphics2D sg2d,
Composite comp, int ctxflags)
{
OGLSurfaceData dstData = (OGLSurfaceData)sg2d.surfaceData;
OGLSurfaceData dstData;
try {
dstData = (OGLSurfaceData) sg2d.surfaceData;
} catch (ClassCastException e) {
throw new InvalidPipeException("wrong surface data type: " +
sg2d.surfaceData);
}
OGLContext.validateContext(dstData, dstData,
sg2d.getCompClip(), comp,
null, sg2d.paint, sg2d, ctxflags);

View File

@ -26,6 +26,7 @@
package sun.java2d.d3d;
import java.awt.Composite;
import sun.java2d.InvalidPipeException;
import sun.java2d.SunGraphics2D;
import sun.java2d.loops.GraphicsPrimitive;
import sun.java2d.loops.GraphicsPrimitiveMgr;
@ -67,7 +68,13 @@ class D3DMaskFill extends BufferedMaskFill {
protected void validateContext(SunGraphics2D sg2d,
Composite comp, int ctxflags)
{
D3DSurfaceData dstData = (D3DSurfaceData)sg2d.surfaceData;
D3DSurfaceData dstData;
try {
dstData = (D3DSurfaceData) sg2d.surfaceData;
} catch (ClassCastException e) {
throw new InvalidPipeException("wrong surface data type: " +
sg2d.surfaceData);
}
D3DContext.validateContext(dstData, dstData,
sg2d.getCompClip(), comp,
null, sg2d.paint, sg2d, ctxflags);

View File

@ -22,10 +22,12 @@
*/
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsEnvironment;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.font.FontRenderContext;
import java.awt.font.GlyphVector;
import java.awt.image.BufferedImage;
@ -99,6 +101,11 @@ public final class ClassCastExceptionForInvalidSurface {
vi.createGraphics().drawString("123", 1, 1);
vi.createGraphics().draw(new Rectangle(0, 0, 10, 10));
vi.createGraphics().fillOval(0, 0, 10, 10);
final Graphics2D graphics = vi.createGraphics();
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
graphics.fillPolygon(new int[] {0, 10, 10, 0},
new int [] {0, 0, 10, 10}, 4);
}
});
t1.start();