< prev index next >

src/java.desktop/unix/classes/sun/java2d/xr/XRRenderer.java

Print this page

        

@@ -26,10 +26,11 @@
 package sun.java2d.xr;
 
 import java.awt.*;
 import java.awt.geom.*;
 import sun.awt.SunToolkit;
+import sun.java2d.InvalidPipeException;
 import sun.java2d.SunGraphics2D;
 import sun.java2d.loops.*;
 import sun.java2d.pipe.Region;
 import sun.java2d.pipe.PixelDrawPipe;
 import sun.java2d.pipe.PixelFillPipe;

@@ -67,11 +68,16 @@
     /**
      * Common validate method, used by all XRRender functions to validate the
      * destination context.
      */
     private final void validateSurface(SunGraphics2D sg2d) {
-        XRSurfaceData xrsd = (XRSurfaceData) sg2d.surfaceData;
+        XRSurfaceData xrsd;
+        try {
+            xrsd = (XRSurfaceData) sg2d.surfaceData;
+        } catch (ClassCastException e) {
+            throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
+        }
         xrsd.validateAsDestination(sg2d, sg2d.getCompClip());
         xrsd.maskBuffer.validateCompositeState(sg2d.composite, sg2d.transform,
                                                sg2d.paint, sg2d);
     }
 
< prev index next >