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) and under Fedora Linux 21 (under Mageia Linux 4 too) with OpenJDK 1.7 update 60 (wrong result). Version-Release number of selected component (if applicable): 1.7 update 60 How reproducible: Always Steps to Reproduce: 1. Compile and run the following test case: import java.awt.BasicStroke; 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.setStroke(new BasicStroke(1.0f,BasicStroke.CAP_BUTT,BasicStroke.JOIN_MITER)); g2.setColor(Color.BLACK); final int delta=3; final int width=20; final int height=20; g2.drawLine(delta,delta,width-delta-1,height-delta-1); g2.drawLine(width-delta-1,delta,delta,height-delta-1); 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 the last points. See the enclosed image. Expected results: A line is drawn between the first and the last point of each line. Additional info: I can't login on OpenJDK bug tracker, that's why I'm posting it here.
Created attachment 922112 [details] diagonal cross wrongly drawn
I tried to disable the Java2D pipeline based on XRender with -Dsun.java2d.xrender=false and the anti-aliasing (by using the rendering hint) but it didn't help.
Hi! I'm not able to reproduce on latest jdk. java version "1.7.0_65" OpenJDK Runtime Environment (fedora-2.5.1.3.fc20-x86_64 u65-b17) OpenJDK 64-Bit Server VM (build 24.65-b04, mixed mode) on my fedora. However the Fedora is not shiping icedtea, so it can cause. Anyway - this is rewritten your reproducer, to exclude some possibel side effects of gui: package crossestest; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Graphics2D; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; public class CrossesTest { /** * @param args the command line arguments */ public static void main(String[] args) throws IOException { BufferedImage i1 = new BufferedImage(46, 24, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = i1.createGraphics(); g2.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER)); g2.setColor(Color.BLACK); final int delta = 3; final int width = 20; final int height = 20; g2.drawLine(delta, delta, width - delta - 1, height - delta - 1); g2.drawLine(width - delta - 1, delta, delta, height - delta - 1); g2.dispose(); ImageIO.write(i1, "png", new File(System.getProperty("user.home")+"/Desktop/i1.png")); } } Does it have same corrupted behaviour? Also, this one is getting rid of cusotm Stroke: package crossestest; import java.awt.Color; import java.awt.Graphics2D; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; public class CrossesTest { /** * @param args the command line arguments */ public static void main(String[] args) throws IOException { BufferedImage i1 = new BufferedImage(46, 24, BufferedImage.TYPE_INT_ARGB); 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(); ImageIO.write(i1, "png", new File(System.getProperty("user.home")+"/Desktop/i1.png")); } } Does it also fail for you?
I'll give a try to your code at home. How could the absence or the presence of icedtea affect the rendering?
Your two test cases don't fail. java version "1.7.0_65" OpenJDK Runtime Environment (mageia-2.5.1.1.mga4-x86_64 u65-b17) OpenJDK 64-Bit Server VM (build 24.65-b04, mixed mode)
Created attachment 922292 [details] test 1
Created attachment 922293 [details] test 2
This test fails but it shows the problems seems to come from the last point :s See i3.png 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); } }); } }
Created attachment 922296 [details] test 3
Created attachment 922488 [details] c8 result hm.. I'm still not bale to reproduce. Attache dis result of comment 8 application
package crossestest; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Graphics2D; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; public class CrossesTest { /** * @param args the command line arguments */ public static void main(String[] args) throws IOException { int c = 0; for (int x1 = 1; x1 <= 22; x1++) { for (int x2 = 1; x2 <= 22; x2++) { for (int y1 = 1; y1 <= 22; y1++) { for (int y2 = 1; y2 <= 22; y2++) { c++; BufferedImage im = new BufferedImage(23, 23, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = im.createGraphics(); //g2.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER)); g2.setColor(Color.red); g2.drawLine(x1, y1, x2, y2); g2.dispose(); int i1 = im.getRGB(x1, y1); int i2 = im.getRGB(x2, y2); Color c1 = new Color(i1); Color c2 = new Color(i2); if (!c1.equals(Color.RED) || !c2.equals(Color.red)) { System.out.println("Failed for "+x1+", "+y1+", "+x2+", "+y2+""); ImageIO.write(im, "png", new File(System.getProperty("user.home") + "/Desktop/i" + c + ".png")); } else { // System.out.println(c + " passed for "+x1+", "+y1+", "+x2+", "+y2+""); } } } } } } } Can you try this? If it will pass for you we can be sure it is issue ow swing. However, I'm really unhappy I can not repreoduce. Can you post more about your system? I have fedora 20, mate, with default window manager. Now I'm trying it also on other fedoras and other window managers and other jdks.
How can it be an issue of Swing whereas my first example doesn't use it (only AWT)? I'll test your example when I'm at home in some hours as usual.
Sorry. I was unclear. I ment generally UI java interface or underlying native code.
Your latest test prints nothing. It seems to confirm your hypothesis. Should I report this bug against Mageia Linux 4?
I have installed the source RPM of OpenJDK "devel", I'll debug the latest test and another one exhibiting the bug on my machine at home. I'll let you know my findings.
I had run your reproducer on: rhel7 64b - jdk6 rhel7 64b - jdk7 rhel7 64b - jdk8 - always gnome3+hnome shell and fluxbox f20 32b - jdk7 - fluxbox and mate f20 64b - jdk7 - cinamon, xfce, mate, openbox, kde(4?), gnome shell And they shown correctly. On gnome shell I had funny issue that during repaint, not always not everything was flushed. Eg only square was painted but not the cross. After more investigions on this issue I come to conclusion that it is not bug. So yes. I would ask you to fill thebug against Mageia - https://bugs.mageia.org/ ? I'm closing now as insufficient data. Please feel free to reopen if Mageia guys will find some jdk cause. Please also attach the lik to magiea bug. maybe if you will share more detaisl about your environment I will be able to reproduce.
Do you think I should install java-1.7.0-openjdk-1.7.0.65-2.5.1.3.fc20.x86_64.rpm under Mageia in order to see how it behaves? I know it isn't very clean.
Bug reported against Mageia: https://bugs.mageia.org/show_bug.cgi?id=13850 Investigation in progress, workaround found, possible root cause found.
I'm seriously looking forward to see the results!
I didn't succeed in installing the Fedora packages under Mageia because of missing dependencies. The bug is probably in the native source code of the old X11 pipeline. As the XRender pipeline is enabled by default on Java 1.8 and not concerned by this bug, I won't fix it, I won't waste any time in fixing a bug in a pipeline that is going to be "replaced".