Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8208996

X11 icon window color handing bug

    Details

    • Resolved In Build:
      b14
    • CPU:
      generic
    • OS:
      linux

      Backports

        Description

        IBM would like to contribute X11 icon window color handing patch to OpenJDK project.

        Issue:
        It seems some of colors on icon for pseudo color are not appropriate.
        Test program is as follows:
        ======
        $ cat IconifiedFrame.java
        import java.awt.*;
        import java.awt.event.*;

        public class IconifiedFrame extends Frame {
          IconifiedFrame() {
            super("IconifiedFrame");
            setSize(100, 100);
            addWindowListener(new WindowAdapter() {
              public void windowClosing(WindowEvent event) { System.exit(0); }
            });
            setExtendedState(Frame.ICONIFIED);
            setVisible(true);
          }
          public static void main(String[] args) {
            new IconifiedFrame();
          }
        }
        ======

        To recreate this issue on RHEL7, please try following steps.
        (xorg-x11-server-Xephyr and openmotif rpm packages are required)

        1. Type following commands from terminal
        $ Xephyr :1 -ac -screen 800x600x8 &
        $ xterm -display :1 &
        2. On xterm on Xephyr
        $ mwm &
        $ javac IconifiedFrame.java
        $ java IconifiedFrame

        Reason:
        Pseudo color is handled by unsigned byte data.
        But Java's byte is signed, it was not converted to unsigned.
        Modified code is as follows:
        ======
        --- old/src/java.desktop/unix/classes/sun/awt/X11/XIconWindow.java 2018-06-13 16:23:17.889946251 +0900
        +++ new/src/java.desktop/unix/classes/sun/awt/X11/XIconWindow.java 2018-06-13 16:23:17.274958922 +0900
        @@ -281,8 +281,9 @@
                         ColorData cdata = adata.get_color_data(0);
                         int num_colors = cdata.get_awt_numICMcolors();
                         for (int i = 0; i < buf.length; i++) {
        - buf[i] = (buf[i] >= num_colors) ?
        - 0 : cdata.get_awt_icmLUT2Colors(buf[i]);
        + int b = Byte.toUnsignedInt(buf[i]);
        + buf[i] = (b >= num_colors) ?
        + 0 : cdata.get_awt_icmLUT2Colors(b);
                         }
                         bytes = Native.toData(buf);
                     } else if (srcBuf instanceof DataBufferInt) {
        ======

        I'd like contribute following 1 file:
        M src/java.desktop/unix/classes/sun/awt/X11/XIconWindow.java

        http://mail.openjdk.java.net/pipermail/awt-dev/2018-June/014043.html

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  serb Sergey Bylokhov
                  Reporter:
                  serb Sergey Bylokhov
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  3 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: