JDK-8054638 : xrender: text drawn after setColor(Color.white) is actually black
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 8u11,9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux
  • CPU: x86
  • Submitted: 2014-07-27
  • Updated: 2015-06-04
  • Resolved: 2014-08-27
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9
8u40Fixed 9 b32Fixed
Related Reports
Duplicate :  
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_11"
Java(TM) SE Runtime Environment (build 1.8.0_11-b12)
Java HotSpot(TM) Server VM (build 25.11-b03, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
Linux t61 3.13.0-32-generic #57-Ubuntu SMP Tue Jul 15 03:51:12 UTC 2014 i686 i686 i686 GNU/Linux

EXTRA RELEVANT SYSTEM CONFIGURATION :
not necessary

A DESCRIPTION OF THE PROBLEM :
White color is not painted. This applies only to Color(255, 255, 255). If
we change it to Color(255, 255, 254), painting works as expected.

This bug only affects Linux; on Windows everything works fine.

REGRESSION.  Last worked in version 7u65

ADDITIONAL REGRESSION INFORMATION: 
java version "1.7.0_65"
Java(TM) SE Runtime Environment (build 1.7.0_65-b17)
Java HotSpot(TM) Server VM (build 24.65-b04, mixed mode)


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Paint any shape in Color.white on Linux system with current JDK 1.8.


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
package com.zetcode;

import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Graphics;
import javax.swing.JFrame;
import javax.swing.JPanel;

class Surface extends JPanel {
    
    public Surface() {
        
        setBackground(Color.black);
    }

    private void doDrawing(Graphics g) {

        g.setColor(new Color(255, 255, 255));
        g.drawString("Bookstore", 50, 50);
    }
    
    @Override
    public void paintComponent(Graphics g) {
        super.paintComponent(g);
        
        doDrawing(g);
    }
}


public class WhiteColorBug extends JFrame {
    
    
    public WhiteColorBug() {
        
        initUI();
    }

    private void initUI() {
        
        add(new Surface());
        
        setSize(280, 270);
        setTitle("White color bug");
        setLocationRelativeTo(null);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);        
    }
    

    public static void main(String[] args) {
        
        EventQueue.invokeLater(new Runnable() {
            
            @Override
            public void run() {                
                WhiteColorBug ex = new WhiteColorBug();
                ex.setVisible(true);                
            }
        });
    }
    
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Paint in Color(255, 255, 254). 


Comments
According to Celmens: "This most likely has been introduced by the composite-operator rework which was done before JDK8". So, most probably issue was introduced in JDK 8. Thus, escape-old label is added.
07-04-2015

This most likely has been introduced by the composite-operator rework which was done before JDK8, as JDK7 builds work fine even with xrender enabled. I'll have a look at this one definitively this week.
11-08-2014

It appears that something in the xrender pipeline believes the text drawing color is white when its actually black, so isn't acting on the setColor() call and propagating it. If you change it to *anything* else (eg 254, 255, 255) it'll draw correctly. Also if you omit the setBackground(Color.black); call you will see the text is drawn in black. Also it appears to be specific to the text drawing as this :- g.setColor(new Color(255, 255, 255)); g.drawRect(20, 20, 100, 100); g.drawString("Bookstore", 50, 50); draws the white rect but not the text. If you draw text in any other colour besides pure white, subsequent drawString calls work fine. -Dsun.java2d.xrender=false cures it.
08-08-2014