-
Bug
-
Resolution: Fixed
-
P3
-
20, 21, 22
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8318739 | 21.0.2 | Laurent Bourgès | P3 | Resolved | Fixed | b05 |
ADDITIONAL SYSTEM INFORMATION :
Linux / OpenJDK 64-Bit Server VM (build 21+35-2513, mixed mode, sharing)
A DESCRIPTION OF THE PROBLEM :
The below source code is expected to create a sharp point at the join of the two lines, and does in all versions of the JVM from about Java through Java 19
In Java 21 the point is being rounded.
It looks to be related to the fact that the shape is very small but drawn through an AffineTransform, and it looks to be related to createStrokedShape: if I simple draw the path, I get a sharp point.
REGRESSION : Last worked in version 19
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the attached, look at the output file "out.png"
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
A sharp point
ACTUAL -
A round point
---------- BEGIN SOURCE ----------
import java.io.*;
import java.awt.*;
import java.awt.image.*;
import java.awt.geom.*;
import javax.imageio.*;
public class Test {
public static void main(String[] args) throws Exception {
// Gives incorrect results in Java 21, correct in Java 19 and earlier.
BufferedImage image = new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB);
Graphics2D g = image.createGraphics();
g.setPaint(Color.WHITE);
g.fillRect(0, 0, 100, 100);
g.setPaint(Color.BLACK);
g.setTransform(new AffineTransform(100, 0, 0, 100, 0, 0));
BasicStroke stroke = new BasicStroke(0.1f, 0, 0, 10);
Path2D p = new Path2D.Float();
p.moveTo(1, 0.2f);
p.lineTo(0.4f, 0.4f);
p.lineTo(1, 0.6f);
Shape outline = stroke.createStrokedShape(p);
g.fill(outline);
g.dispose();
ImageIO.write(image, "png", new File("out.png"));
}
}
---------- END SOURCE ----------
FREQUENCY : always
Linux / OpenJDK 64-Bit Server VM (build 21+35-2513, mixed mode, sharing)
A DESCRIPTION OF THE PROBLEM :
The below source code is expected to create a sharp point at the join of the two lines, and does in all versions of the JVM from about Java through Java 19
In Java 21 the point is being rounded.
It looks to be related to the fact that the shape is very small but drawn through an AffineTransform, and it looks to be related to createStrokedShape: if I simple draw the path, I get a sharp point.
REGRESSION : Last worked in version 19
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the attached, look at the output file "out.png"
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
A sharp point
ACTUAL -
A round point
---------- BEGIN SOURCE ----------
import java.io.*;
import java.awt.*;
import java.awt.image.*;
import java.awt.geom.*;
import javax.imageio.*;
public class Test {
public static void main(String[] args) throws Exception {
// Gives incorrect results in Java 21, correct in Java 19 and earlier.
BufferedImage image = new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB);
Graphics2D g = image.createGraphics();
g.setPaint(Color.WHITE);
g.fillRect(0, 0, 100, 100);
g.setPaint(Color.BLACK);
g.setTransform(new AffineTransform(100, 0, 0, 100, 0, 0));
BasicStroke stroke = new BasicStroke(0.1f, 0, 0, 10);
Path2D p = new Path2D.Float();
p.moveTo(1, 0.2f);
p.lineTo(0.4f, 0.4f);
p.lineTo(1, 0.6f);
Shape outline = stroke.createStrokedShape(p);
g.fill(outline);
g.dispose();
ImageIO.write(image, "png", new File("out.png"));
}
}
---------- END SOURCE ----------
FREQUENCY : always
- backported by
-
JDK-8318739 BasicStroke.createStrokedShape miter-limits failing on small shapes
- Resolved
- relates to
-
JDK-8297230 Update Marlin2D to 0.9.4.6
- Resolved
- links to
-
Commit openjdk/jdk21u/0fc04fb1
-
Commit openjdk/jdk/a876beb6
-
Review openjdk/jdk21u/279
-
Review openjdk/jdk/16002
(1 links to)