IDEA-156975 CCE: GraphicsDDelegate.drawPolygon

Extended CCE fix to D3D pipeline
diff --git a/idea/java/windows/windows.iml b/idea/java/windows/windows.iml
new file mode 100644
index 0000000..35d7979
--- /dev/null
+++ b/idea/java/windows/windows.iml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+  <component name="NewModuleRootManager" inherit-compiler-output="true">
+    <exclude-output />
+    <content url="file://$MODULE_DIR$/../../../src/windows">
+      <sourceFolder url="file://$MODULE_DIR$/../../../src/windows/classes" isTestSource="false" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="module" module-name="share" />
+  </component>
+</module>
\ No newline at end of file
diff --git a/src/windows/classes/sun/java2d/d3d/D3DMaskFill.java b/src/windows/classes/sun/java2d/d3d/D3DMaskFill.java
index e5e3d25..ac9e59e 100644
--- a/src/windows/classes/sun/java2d/d3d/D3DMaskFill.java
+++ b/src/windows/classes/sun/java2d/d3d/D3DMaskFill.java
@@ -26,6 +26,8 @@
 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 +69,12 @@
     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);
diff --git a/test/sun/java2d/ClassCastExceptionForInvalidSurface.java b/test/sun/java2d/ClassCastExceptionForInvalidSurface.java
index 985ed24..b81dec8 100644
--- a/test/sun/java2d/ClassCastExceptionForInvalidSurface.java
+++ b/test/sun/java2d/ClassCastExceptionForInvalidSurface.java
@@ -96,8 +96,10 @@
                 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);
+                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();