Bug 13850 - Graphics2D.drawLine() wrongly draws the first (or the last) point
Summary: Graphics2D.drawLine() wrongly draws the first (or the last) point
Status: RESOLVED OLD
Alias: None
Product: Mageia
Classification: Unclassified
Component: RPM Packages (show other bugs)
Version: 4
Hardware: All Linux
Priority: Normal major
Target Milestone: ---
Assignee: Mageia Bug Squad
QA Contact:
URL: https://bugzilla.redhat.com/show_bug....
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-08-03 19:27 CEST by Julien Gouesse
Modified: 2015-10-27 06:56 CET (History)
1 user (show)

See Also:
Source RPM: java-1.7.0-openjdk-1.7.0.65-2.5.1.1.mga4.src.rpm
CVE:
Status comment:


Attachments

Description Julien Gouesse 2014-08-03 19:27:08 CEST
Description of problem:
I try to draw a diagonal cross and I get a different result with the same code under Microsoft Windows with Oracle Java 1.7 update 60 (expected result), under Fedora Linux 20 (expected result according to Jiri Vanek) and under Mageia Linux 4 (wrong result) with OpenJDK 1.7 update 60 and OpenJDK 1.7 update 65.

Version-Release number of selected component (if applicable):
1.7 update 60 and 1.7 update 65

How reproducible:
Always

Steps to Reproduce:
1. Run the example above
2. 
3.

import java.awt.Canvas;
import java.awt.Color;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.SwingUtilities;


public class Test {

	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			
			@Override
			public void run() {
				Frame frame=new Frame();
				frame.add(new Canvas(){
					private static final long serialVersionUID = 1L;

					@Override
					public void paint(Graphics g){
						final Graphics2D g2=(Graphics2D)g.create();
			            g2.setColor(Color.blue);
			            g2.drawRect(1 ,1, 21, 21);
			            g2.drawLine(3,3, 20,20);
			            g2.drawLine(3,20, 20,3);
			            g2.dispose();
					}
				});
				frame.setSize(600,600);
				frame.addWindowListener(new WindowAdapter() {
					@Override
					public void windowClosing(WindowEvent we) {
						System.exit(0);
					}
				});
				frame.setVisible(true);
			}
		});
	}
}

Actual results:
The drawing goes beyond the first and/or the last points. The distance from the first point to the intersection isn't the same than the distance from the intersection to the last point. In this example, it seems to go beyond the first point: https://bugzilla.redhat.com/attachment.cgi?id=922112

Expected results:
A line is drawn between the first and the last point of each line.

Reproducible: 

Steps to Reproduce:
Julien Gouesse 2014-08-03 19:27:22 CEST

CC: (none) => gouessej

Julien Gouesse 2014-08-03 19:27:38 CEST

Hardware: i586 => All

Comment 1 Julien Gouesse 2014-08-03 21:01:19 CEST
Note that this modified example isn't concerned by this bug:
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;

import javax.swing.SwingUtilities;


public class Test {

	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			
			@Override
			public void run() {
				Frame frame=new Frame();
				frame.add(new Canvas(){
					private static final long serialVersionUID = 1L;

					BufferedImage i1 = new BufferedImage(46, 24, BufferedImage.TYPE_INT_ARGB);
					
					@Override
					public void paint(Graphics g){
				        Graphics2D g2 = i1.createGraphics();
			            g2.setColor(Color.blue);
			            g2.drawRect(1 ,1, 21, 21);
			            g2.drawLine(3,3, 20,20);
			            g2.drawLine(3,20, 20,3);
			            g2.dispose();
			            g.drawImage(i1, 0, 0, this);
					}
				});
				frame.setSize(600,600);
				frame.addWindowListener(new WindowAdapter() {
					@Override
					public void windowClosing(WindowEvent we) {
						System.exit(0);
					}
				});
				frame.setVisible(true);
			}
		});
	}
}
Comment 2 Julien Gouesse 2014-08-03 21:07:38 CEST
sun.java2d.loops.DrawLine.DrawLine() (method called in the second example) works as expected whereas sun.java2d.x11.X11Renderer.drawLine() (method called in the first example) doesn't work as expected.
Comment 3 Julien Gouesse 2014-08-03 21:25:16 CEST
sun.java2d.pipe.BufferedRenderPipe.drawLine() works as expected. I use these options to force the use of the OpenGL pipeline instead of the XRender pipeline:
-Dsun.java2d.xrender=False -Dsun.java2d.opengl=True

This message is displayed when running the first example:
OpenGL pipeline enabled for default config on screen 0

I've just tested this workaround on a larger application and it works.
Comment 4 Julien Gouesse 2014-08-04 11:34:00 CEST
Sorry for the confusion, sun.java2d.x11.X11Renderer.drawLine() is a method of the old X11 renderer, not from the XRender Java2D pipeline which is used by default in OpenJDK 8.
Comment 5 Julien Gouesse 2014-08-04 14:41:20 CEST
Please backport this RPM package so that I can work in good conditions:
java-1.8.0-openjdk-1.8.0.0-2.b132.3.mga5.src.rpm

I'd like to confirm whether nothing has been broken when packaging OpenJDK for Mageia as soon as possible:
http://mail.openjdk.java.net/pipermail/2d-dev/2014-August/004717.html
Comment 6 David Walser 2014-08-05 00:38:54 CEST
We can't support an official backport.  I have just updated java-1.8.0-openjdk in Cauldron to the latest version.  It should run fine on Mageia 4.

The next step for that package in Cauldron is to try to get the java8 support in the timezone package building, and then make the same change Fedora did in java-1.8.0-openjdk to make it use the system tzdb.dat file from timezone-java, as well as making it obsolete java-1.7.0-openjdk, neither of which you'd want in Mageia 4.  So, please download the packages from the java-1.8.0-openjdk-1.8.0.11-3.b12.0.mga5 build ASAP (if the timezone thing works, I'll do that tomorrow, probably morning).  You'll need most if not all of the java-1.8.0-openjdk-*.rpm.
Comment 7 Julien Gouesse 2014-08-05 08:13:59 CEST
Hi

Thank you so much. OpenJDK 1.8 uses sun.java2d.xr.XRRenderer by default which isn't concerned by this bug, I've just run JFPSM, the diagonal cross is drawn correctly in each new tab. I feel better now.
Comment 8 David Walser 2014-08-05 16:41:49 CEST
Just FYI, I've done the newer build that I mentioned in Comment 6.  If you want to use it and future Java 8 builds on Mageia 4, you'll just need to know that it'll obsolete/uninstall java-1.7.0-openjdk, and you'll need to build your own backport of the timezone package on Mageia 4.
Comment 9 Samuel Verschelde 2015-09-21 13:19:17 CEST
Mageia 4 changed to end-of-life (EOL) status on 2015-09-19. It is is no longer 
maintained, which means that it will not receive any further security or bug 
fix updates.

Package Maintainer: If you wish for this bug to remain open because you plan to 
fix it in a currently maintained version, simply change the 'version' to a later 
Mageia version.

Bug Reporter: Thank you for reporting this issue and we are sorry that we weren't 
able to fix it before Mageia 4's end of life. If you are able to reproduce it 
against a later version of Mageia, you are encouraged to click on "Version" and 
change it against that version of Mageia. If it's valid in several versions, 
select the highest and add MGAxTOO in whiteboard for each other valid release.
Example: it's valid in cauldron and Mageia 5, set to cauldron and add MGA5TOO.

Although we aim to fix as many bugs as possible during every release's lifetime, 
sometimes those efforts are overtaken by events. Often a more recent Mageia 
release includes newer upstream software that fixes bugs or makes them obsolete.

If you would like to help fixing bugs in the future, don't hesitate to join the
packager team via our mentoring program [1] or join the teams that fit you 
most [2].

[1] https://wiki.mageia.org/en/Becoming_a_Mageia_Packager
[2] http://www.mageia.org/contribute/
Comment 10 Marja Van Waes 2015-10-27 06:56:43 CET
As announced over a month ago, Mageia 4 changed to end-of-life (EOL) status on 2015-09-19. It is is no longer maintained, which means that it will not receive any further security or bug fix updates.

This issue may have been fixed in a later Mageia release, so, if you still see it and didn't already do so: please upgrade to Mageia 5 (or, if you read this much later than this is written: make sure you run a currently maintained Mageia version)

If you are able to reproduce it against a maintained version of Mageia, you are encouraged to 
1. reopen this bug report, by changing the "Status" from "RESOLVED - OLD" to "REOPENED"
2. click on "Version" and change it against that version of Mageia. If you know it's valid in several versions, select the highest and add MGAxTOO in whiteboard for each other valid release.
Example: it's valid in cauldron and Mageia 5, set to cauldron and add MGA5TOO.
3. give as much relevant information as possible. If you're not an experienced bug reporter and have some time: please read this page:
https://wiki.mageia.org/en/How_to_report_a_bug_properly

If you see a similar issue, but are _not_sure_ it is the same, with the same cause, then please file a new bug report and mention this one in it (please include the bug number, too). 


If you would like to help fixing bugs in the future, don't hesitate to join the
packager team via our mentoring program [1] or join the teams that fit you 
most [2].
[1] https://wiki.mageia.org/en/Becoming_a_Mageia_Packager
[2] http://www.mageia.org/contribute/

Status: NEW => RESOLVED
Resolution: (none) => OLD


Note You need to log in before you can comment on or make changes to this bug.