FULL PRODUCT VERSION :
java version "1.7.0_05"
Java(TM) SE Runtime Environment (build 1.7.0_05-b06)
Java HotSpot(TM) Client VM (build 23.1-b03, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
Also reproduced on Windows 7
A DESCRIPTION OF THE PROBLEM :
The bug applies to AWT applications (standalone and applet). The Direct3D pipeline should be enabled. If you first do a drawImage and then a XOR operation then the image won't appear.
Tested on:
1.6.0_14: OK
1.6.0_32: OK
1.7.0-b147: FAIL
1.7.0_05-b06: FAIL
REGRESSION. Last worked in version 6u31
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
In your constructor you should create a BufferedImage img.
In your paint method you should do:
1. drawImage(img)
2. setXORMode
3. do something
4. setPaintMode
#!/bin/sh
java -cp . -Dsun.java2d.trace=log,verbose TestCase 0 > no_d3d.log 2>&1
export J2D_D3D=true
export J2D_D3D_NO_HWCHECK=true
java -cp . -Dsun.java2d.trace=log,verbose TestCase 0 > d3d_problem.log 2>&1
java -cp . -Dsun.java2d.trace=log,verbose TestCase 1 > d3d_workaround1.log 2>&1
java -cp . -Dsun.java2d.trace=log,verbose TestCase 2 > d3d_workaround2.log 2>&1
java -cp . -Dsun.java2d.trace=log,verbose TestCase 3 > d3d_workaround3.log 2>&1
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
To see the img.
ACTUAL -
The img will flash and then disappear.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
In the "Steps to Reproduce" there is a script attached to generate useful log files.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.Color;
import java.awt.Frame;
import java.awt.Graphics2D;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.util.Timer;
import java.util.TimerTask;
public class TestCase extends Frame {
private BufferedImage image;
public int workaround;
public void init() {
System.out.println("init enter");
image = new BufferedImage(200, 200, BufferedImage.TYPE_INT_RGB);
Graphics2D g = image.createGraphics();
g.setColor(Color.GREEN);
g.fillRect(0,0,200,200);
g.setColor(Color.RED);
g.drawString("Hello, world!", 65, 100);
System.out.println("init exit");
Timer timer = new Timer();
timer.schedule(new TerminateTask(), 3000);
}
public void paint(Graphics g) {
System.out.println("paint enter");
if (workaround != 0) {
System.out.println(" applying workaround " + workaround);
}
switch (workaround) {
case 1:
g.setXORMode(Color.WHITE);
g.drawLine(0, 0, 0, 0);
g.setPaintMode();
break;
case 2:
Graphics2D gg = image.createGraphics();
gg.drawLine(0, 0, 0, 0);
break;
case 3:
image.setRGB(0, 0, image.getRGB(0, 0));
break;
}
g.drawImage(image, 0, 0, null);
g.setXORMode(Color.WHITE);
g.drawLine(0, 0, 0, 0);
g.setPaintMode();
System.out.println("paint exit");
}
public static void main(String args[]) {
TestCase x = new TestCase();
x.workaround = Integer.parseInt(args[0]);
x.init();
x.setSize(200, 200);
x.setVisible(true);
}
class TerminateTask extends TimerTask {
public void run() {
System.exit(0);
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
There are 3 workarounds in the source code.