United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7153339 InternalError when drawLine with Xor and Antialiasing
JDK-7153339 : InternalError when drawLine with Xor and Antialiasing

Details
Type:
Bug
Submit Date:
2012-03-13
Status:
Closed
Updated Date:
2013-07-04
Project Name:
JDK
Resolved Date:
2012-09-25
Component:
client-libs
OS:
generic,windows_7
Sub-Component:
2d
CPU:
x86,generic
Priority:
P2
Resolution:
Fixed
Affected Versions:
6u29,7u3,8
Fixed Versions:

Related Reports
Backport:
Backport:

Sub Tasks

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
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.
                                     
2012-03-13
URL:   http://hg.openjdk.java.net/jdk8/build/jdk/rev/d14dc0ae1c2c
User:  katleman
Date:  2012-09-27 06:14:08 +0000

                                     
2012-09-27
Test passed!
                                     
2013-04-17
RULE 2D_Geometry/Automated/DrawLineWithXorAndAntialiasingTest Crash any
                                     
2013-07-04



Hardware and Software, Engineered to Work Together