JDK-6269884 : Regression: Multibyte Text can not be displayed in title bar of JFrame, Message box, and JDialog
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.0,6
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS:
    generic,linux,linux_suse_sles_8.2,solaris_9,windows_2003 generic,linux,linux_suse_sles_8.2,solaris_9,windows_2003
  • CPU: generic,x86,sparc
  • Submitted: 2005-05-13
  • Updated: 2011-03-14
  • Resolved: 2005-08-06
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 6
6 b47Fixed
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Description
This happens on gnome and CDE (X windows system). We use testsuits provided by java sqe team to find i18n bugs by comparing GUIs between latest and old jdk build. In the automated generated testing report, from b35, text in asian languges like S. Chinese, T.Chinese, and Korean can not be displayed on titlebar of java frame, message box and dialogue. This problem does not happen in Mircrosoft OS, though the appearence of the titlebar is a little different from previous version.

http://sqeweb.sfbay/st3/jdk6.0/i18n/reports/ea/results/b35/i18n-zh_CN/RedhatAS_x86-03-zh_CN.gb18030/GlobalSuite-MS-Report.html
http://sqeweb.sfbay/st3/jdk6.0/i18n/reports/ea/results/b35/i18n-zh_CN/Solaris10_sparc-jds3-zh_CN.utf8/GlobalSuite-MS-Report.html

To confirm that this is not a sqe test suite bug. I wrote a small java class to display java message box with S. Chinese text in titlebar. When user click button "push" on the frame, a message box will popup. The text in local language is in the title bar of the message box. Until b34, the text can be displayed on title bar. From b35, the native text can not be displayed on title bar of the message box. This only happens on linux/unix with gnome or cde desktop. The text still can be displayed on windows platform.

Blow is the source code. The screenshots of message box in b34 and b35 are in the attachment.

/*
 * JFrame1.java
 *
 * Created on 
 */

/**
 *
 * @author  Administrator
 */

import javax.swing.*;

public class JFrame1 extends javax.swing.JFrame {
    
    /** Creates new form JFrame1 */
    public JFrame1() {
        initComponents();
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        jPanel1 = new javax.swing.JPanel();
        jOptionPane1 = new javax.swing.JOptionPane();
        jButton1 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        jPanel1.add(jOptionPane1);

        jButton1.setText("push");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jPanel1.add(jButton1);

        getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);

        pack();
    }
    // </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        JOptionPane.showConfirmDialog(this,"Welcome","\u4e2d\u6587\u6d4b\u8bd5",JOptionPane.YES_NO_OPTION);// TODO add your handling code here:
    }//GEN-LAST:event_jButton1ActionPerformed
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new JFrame1().setVisible(true);
            }
        });
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JOptionPane jOptionPane1;
    private javax.swing.JPanel jPanel1;
    // End of variables declaration//GEN-END:variables
    
}
###@###.### 2005-05-13 07:49:13 GMT

It happens on RHAS 4.0 in DE locale. See report at http://sqeweb.sfbay/st3/jdk6.0/i18n/reports/ea/results/b35/i18n-de/RHAS_AMD64-4.0-de.DE-UTF8/GlobalSuite-MS-Report.html

###@###.### 2005-05-13 12:18:09 GMT
###@###.### 2005-05-13 12:36:44 GMT

Comments
EVALUATION verified on b54 with RHAS4.0, de_DE.UTF-8 locale.
14-10-2005

EVALUATION Regression from the fix for 4931668. XlibWrapper_SetProperty has been modified to handle multi-dimensions strings, however with several mistakes (see 6271042). The one which causes this problem: when working with UTF strings, length must be calculated using GetStringUTFLength. ###@###.### 2005-05-17 11:37:20 GMT Unfortunately, in case of no UTFStrings available (Xsun) fix provided doesn't work with wide platform characters because length estimation is too small. In jni utilities there seems to be no tool to calculate wide string byte length; this value is calculated and discarded in JNU_GetStringPlatformChars() after converting internal UTF-8 string representation to a platform encoding. Is there a way to return this length along with a null terminated result of conversion? ###@###.### 2005-07-06 12:41:00 GMT As it happens, we never invoke native SetProperty function with a list of null-terminated strings. So we'll rollback a change proposed in xembed branch and will always call X*TextListToTextProperty functions with count==1. That seems to fix this bug. In fact, I'm not sure any Xlib _can_ process X*TextListToTextProperty() with a count>1 smoothly for all locales. ###@###.### 2005-07-14 12:24:33 GMT
17-05-2005

SUGGESTED FIX *** /tmp/geta12949.y12952 2005-05-17 15:47:12.372470640 +0400 --- XlibWrapper.c 2005-05-17 15:46:37.024844296 +0400 *************** *** 627,634 **** XTextProperty tp; int32_t status; int count = 0, pos = 0, length = 0; ! char * charPtr = NULL; ! char ** list = NULL, **list_ptr = NULL; /* In case there are direct support of UTF-8 declared, use UTF-8 strings. --- 627,634 ---- XTextProperty tp; int32_t status; int count = 0, pos = 0, length = 0; ! char * charPtr = NULL, *prev_charPtr = NULL; ! char ** list = NULL, **list_ptr = NULL; /* In case there are direct support of UTF-8 declared, use UTF-8 strings. *************** *** 643,664 **** cname = ""; } length = (*env)->GetStringLength(env, jstr); ! list = malloc(length * sizeof(char*)); // Definitely not bigger than this list_ptr = list; // Count number of sub-items ! charPtr = cname; ! *(list_ptr++) = charPtr; while (pos <= length) { if (!*charPtr) { count++; ! *(list_ptr)++ = charPtr+1; } pos++; charPtr++; } #ifdef X_HAVE_UTF8_STRING status = Xutf8TextListToTextProperty((Display *)jlong_to_ptr(display), list, count, --- 643,669 ---- cname = ""; } + #ifdef X_HAVE_UTF8_STRING + length = (*env)->GetStringUTFLength(env, jstr); + #else length = (*env)->GetStringLength(env, jstr); ! #endif ! list = malloc((length+1) * sizeof(char*)); // Definitely not bigger than this list_ptr = list; // Count number of sub-items ! charPtr = prev_charPtr = cname; while (pos <= length) { if (!*charPtr) { count++; ! *(list_ptr++) = prev_charPtr; ! prev_charPtr = charPtr+1; } pos++; charPtr++; } + AWT_CHECK_HAVE_LOCK(); #ifdef X_HAVE_UTF8_STRING status = Xutf8TextListToTextProperty((Display *)jlong_to_ptr(display), list, count, *************** *** 671,677 **** free(list); if (status == Success || status > 0) { - AWT_CHECK_HAVE_LOCK(); XChangeProperty((Display *)jlong_to_ptr(display), window, atom, tp.encoding, tp.format, PropModeReplace, tp.value, tp.nitems); if (tp.value != NULL) { XFree(tp.value); --- 676,681 ---- ###@###.### 2005-05-17 11:48:23 GMT
17-05-2005