JDK-7153339 : InternalError when drawLine with Xor and Antialiasing
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 6u29,7u3,8
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic,windows_7
  • CPU: generic,x86
  • Submitted: 2012-03-13
  • Updated: 2014-10-24
  • Resolved: 2012-09-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 7 JDK 8
7u40Fixed 8 b58Fixed
Description
FULL PRODUCT VERSION :
java version "1.6.0_31"
Java(TM) SE Runtime Environment (build 1.6.0_31-b05)
Java HotSpot(TM) Client VM (build 20.6-b01, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]

A DESCRIPTION OF THE PROBLEM :
java.lang.InternalError when first invoke "Graphics2D.drawLine" on mouseMoved. XorMode and Antialiasing enabled.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
no errors
ACTUAL -
exception on first drawLine

ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.InternalError: Unable to Stroke shape (attempt to validate Pipe with invalid SurfaceData)
	at sun.java2d.pipe.LoopPipe.getStrokeSpans(LoopPipe.java:282)
	at sun.java2d.pipe.LoopPipe.draw(LoopPipe.java:182)
	at sun.java2d.pipe.PixelToShapeConverter.drawLine(PixelToShapeConverter.java:34)
	at sun.java2d.pipe.ValidatePipe.drawLine(ValidatePipe.java:44)
	at sun.java2d.SunGraphics2D.drawLine(SunGraphics2D.java:2111)
	at TestX$MyComp.paintLine(TestX.java:44)
	at TestX$MyComp.mouseMoved(TestX.java:29)
	at java.awt.Component.processMouseMotionEvent(Component.java:6335)
	at javax.swing.JComponent.processMouseMotionEvent(JComponent.java:3285)
	at java.awt.Component.processEvent(Component.java:6059)
	at java.awt.Container.processEvent(Container.java:2039)
	at java.awt.Component.dispatchEventImpl(Component.java:4653)
	at java.awt.Container.dispatchEventImpl(Container.java:2097)
	at java.awt.Component.dispatchEvent(Component.java:4481)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4575)
	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4249)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4166)
	at java.awt.Container.dispatchEventImpl(Container.java:2083)
	at java.awt.Window.dispatchEventImpl(Window.java:2482)
	at java.awt.Component.dispatchEvent(Component.java:4481)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:648)
	at java.awt.EventQueue.access$000(EventQueue.java:84)
	at java.awt.EventQueue$1.run(EventQueue.java:607)
	at java.awt.EventQueue$1.run(EventQueue.java:605)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)
	at java.awt.EventQueue$2.run(EventQueue.java:621)
	at java.awt.EventQueue$2.run(EventQueue.java:619)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:618)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.event.*;

import javax.swing.*;

public class TestX
{
	public static void main(String[] args)
	{
		JFrame f = new JFrame();
		f.add(new MyComp());

		f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		f.setSize(500, 500);
		f.setLocationRelativeTo(null);
		f.setVisible(true);
	}

	private static class MyComp extends JLabel implements MouseMotionListener
	{
		public MyComp()
		{
			addMouseMotionListener(this);
		}

		@Override
		public void mouseMoved(MouseEvent e)
		{
			paintLine(getBackground(), (Graphics2D) getGraphics());
		}

		protected static void paintLine(Color bg, Graphics2D g2D)
		{
			g2D.setXORMode(bg);
			g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

			int x1 = 100;
			int y1 = 100;
			int x2 = 200;
			int y2 = 200;

			try
			{
				g2D.drawLine(x1, y1, x2, y2);
			}
			catch (InternalError e)
			{
				e.printStackTrace();
			}
		}

		@Override
		public void mouseDragged(MouseEvent e)
		{
		}
	}
}
---------- END SOURCE ----------

Comments
It's impossible to write a test, because exception is catched by EDT loop.
06-09-2013

RULE 2D_Geometry/Automated/DrawLineWithXorAndAntialiasingTest Crash any
04-07-2013

Test passed!
17-04-2013

EVALUATION This was introduced by the fix for 7112642: Incorrect checking for graphics rendering object which was fixed in JDk 8 b28 and backjported to 7u3 and 6u31 b02 .. The test looks valid to me, so we'll need to fix across releases.
13-03-2012