Details
-
Bug
-
Resolution: Fixed
-
P4
-
11.0.3-oracle
-
b19
-
x86_64
-
windows_10
Backports
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8289784 | 17.0.5-oracle | Manukumar V S | P4 | Resolved | Fixed | b01 |
JDK-8291787 | 17.0.5 | Goetz Lindenmaier | P4 | Resolved | Fixed | b02 |
JDK-8289785 | 11.0.17-oracle | Manukumar V S | P4 | Resolved | Fixed | b01 |
JDK-8291844 | 11.0.17 | Goetz Lindenmaier | P4 | Resolved | Fixed | b02 |
JDK-8289802 | 8u351 | Manukumar V S | P4 | Resolved | Fixed | b01 |
Description
all OS-es (issues 1-3) / macOS 10.14+ (issue 4)
jdk1.8.0_212 / jdk-11.0.3 / jdk-12.0.1
A DESCRIPTION OF THE PROBLEM :
Regression test java/awt/Graphics2D/DrawString/LCDTextSrcEa.java has the following issues:
(all OS-es)
1) LCDTextSrcEa paint(Graphics gx) method must be invoked for proper testing, but it cannot always be so when running under jtreg. LCDTextSrcEa main() method may finish before the actual paint(Graphics gx) execution. And jtreg immediately calls System.exit() when test method main() has finished. Jtreg won't wait for EDT to complete. So some check is needed in the test main() method to ensure paint(Graphics gx) has been completed. Otherwise the test may erroneously pass under jtreg.
2) It is not good to throw exception from the test paint(Graphics gx) / EDT. Jtreg handles uncaught exceptions even from EDT because it launches tests in a separate ThreadGroup overriding uncaughtException(Thread t,Throwable e) method. But the test cannot properly work using command "java <test>". RuntimeException("No LCD text found") thrown from EDT won't stop the test execution in this case.
3) Also the test Frame is not disposed at the end, so the test cannot finish when running under java as "java <test>". It is not a problem for jtreg though, because, as noted above, it finishes the test execution immediately after the test method main() finishes.
(macOS Mojave)
4) The following command should be applied on macOS 10.14+ Mojave for the proper test run:
"defaults write -g CGFontRenderingFontSmoothingDisabled -bool NO", otherwise the test fails.
It is because LCD shader cannot be used on macOS 10.14+ in font rendering unless it is explicitly specified by CGFontRenderingFontSmoothingDisabled system property.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the following commands for the test execution simply using java:
cd <jdk_test_src>
<jdk_home>/bin/javac java/awt/Graphics2D/DrawString/LCDTextSrcEa.java
<jdk_home>/bin/java -cp java/awt/Graphics2D/DrawString LCDTextSrcEa.java
Run the following commands for the test execution using jtreg:
cd <jdk_test_src>
<jtreg_home>/bin/jtreg -testjdk:<jdk_home> java/awt/Graphics2D/DrawString/LCDTextSrcEa.java
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Correct test execution
ACTUAL -
Test may erroneously pass under jtreg
Test cannot finish when run as "java <test>"
Test always fails on macOS 10.14+
---------- BEGIN SOURCE ----------
/**
* @test
* @key headful
* @bug 6996867
* @summary Render as LCD Text in SrcEa composite mode.
*/
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
public class LCDTextSrcEa extends Component {
static int SZ=150;
BufferedImage target =
new BufferedImage(SZ, SZ, BufferedImage.TYPE_INT_RGB);
public static void main(String args[]) {
Frame f = new Frame("LCD Text SrcEa Test");
f.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
LCDTextSrcEa td = new LCDTextSrcEa();
f.add("Center", td);
f.pack();
f.setVisible(true);
}
public Dimension getPreferredSize() {
return new Dimension(SZ,SZ);
}
public void paint(Graphics gx) {
Graphics2D g2d = (Graphics2D) target.getGraphics();
g2d.setColor(Color.white);
g2d.fillRect(0, 0, getWidth(), getHeight());
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC, 0.01f));
g2d.setRenderingHint(
RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_VBGR);
g2d.setRenderingHint(
RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setColor(Color.black);
g2d.drawString("Some sample text.", 10, 20);
gx.drawImage(target, 0, 0, null);
boolean nongrey = false;
//Test BI: should be some non-greyscale color
for (int px=0;px<SZ;px++) {
for (int py=0;py<SZ;py++) {
int rgb = target.getRGB(px, py);
int r = (rgb & 0xff0000) >> 16;
int g = (rgb & 0x00ff00) >> 8;
int b = (rgb & 0x0000ff);
if (r != g || r !=b || g != b) {
nongrey=true;
break;
}
}
}
if (!nongrey) {
throw new RuntimeException("No LCD text found");
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Here is the modified test with the possible fixes for issues 1)-3).
/**
* @test
* @key headful
* @bug 6996867
* @summary Render as LCD Text in SrcEa composite mode.
*/
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
public class LCDTextSrcEa extends Component {
private static final int TIMEOUT = 20000;
private static volatile boolean nongrey = false;
private static CountDownLatch latch = new CountDownLatch(1);
static int SZ=150;
BufferedImage target =
new BufferedImage(SZ, SZ, BufferedImage.TYPE_INT_RGB);
public static void main(String args[]) throws InterruptedException {
Frame f = new Frame("LCD Text SrcEa Test");
f.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
LCDTextSrcEa td = new LCDTextSrcEa();
f.add("Center", td);
f.pack();
f.setVisible(true);
if(!latch.await(TIMEOUT, TimeUnit.MILLISECONDS)) {
throw new RuntimeException("ERROR: Test paint method has not finished for " + TIMEOUT + "msec");
}
f.dispose();
if (!nongrey) {
throw new RuntimeException("No LCD text found");
}
}
public Dimension getPreferredSize() {
return new Dimension(SZ,SZ);
}
public void paint(Graphics gx) {
Graphics2D g2d = (Graphics2D) target.getGraphics();
g2d.setColor(Color.white);
g2d.fillRect(0, 0, getWidth(), getHeight());
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC, 0.01f));
g2d.setRenderingHint(
RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_VBGR);
g2d.setRenderingHint(
RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setColor(Color.black);
g2d.drawString("Some sample text.", 10, 20);
gx.drawImage(target, 0, 0, null);
//Test BI: should be some non-greyscale color
for (int px=0;px<SZ;px++) {
for (int py=0;py<SZ;py++) {
int rgb = target.getRGB(px, py);
int r = (rgb & 0xff0000) >> 16;
int g = (rgb & 0x00ff00) >> 8;
int b = (rgb & 0x0000ff);
if (r != g || r !=b || g != b) {
nongrey=true;
break;
}
}
}
latch.countDown();
}
}
FREQUENCY : always
Attachments
Issue Links
- backported by
-
JDK-8289784 [TESTBUG] Regression test java/awt/Graphics2D/DrawString/LCDTextSrcEa.java has issues
- Resolved
-
JDK-8289785 [TESTBUG] Regression test java/awt/Graphics2D/DrawString/LCDTextSrcEa.java has issues
- Resolved
-
JDK-8289802 [TESTBUG] Regression test java/awt/Graphics2D/DrawString/LCDTextSrcEa.java has issues
- Resolved
-
JDK-8291787 [TESTBUG] Regression test java/awt/Graphics2D/DrawString/LCDTextSrcEa.java has issues
- Resolved
-
JDK-8291844 [TESTBUG] Regression test java/awt/Graphics2D/DrawString/LCDTextSrcEa.java has issues
- Resolved
- links to
-
Commit openjdk/jdk11u-dev/9796aac8
-
Commit openjdk/jdk17u-dev/53cb0028
-
Commit openjdk/jdk/d41331e6
-
Review openjdk/jdk11u-dev/1303
-
Review openjdk/jdk17u-dev/619
-
Review openjdk/jdk/8227