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

setWMClass fails to null-terminate WM_CLASS string

    Details

    • Subcomponent:
    • Resolved In Build:
      b105
    • CPU:
      generic
    • OS:
      solaris

      Backports

        Description

        While debugging a port of the classic xwininfo command from the libX11 to libxcb
        API's, I noted that the class info shown for some java windows contained bogus
        extra characters on the end.

        For instance, while the Xlib version of xwinfo showed:
            0x5400010 "FocusProxy": ("Focus-Proxy-Window" "FocusProxy") 1x1+-1+-1 +1313+1

        the xcb version showed:
            0x5400010 "FocusProxy": ("Focus-Proxy-Window" "FocusProxyFra1") 1x1+-1+-1 +1313+1

        Digging into this, I discovered that Xlib was hiding a bug in Java. Xlib always
        adds a trailing '\0' byte to property strings, while xcb does not. This exposes
        that Java is not including the trailing '\0' when setting the WM_CLASS string - from
        XBaseWindow.java:

            void setWMClass(String[] cl) {
                if (cl.length != 2) {
                    throw new IllegalArgumentException("WM_CLASS_NAME consists of exactly two strings");
                }
                XToolkit.awtLock();
                try {
                    XAtom xa = XAtom.get(XAtom.XA_WM_CLASS);
                    xa.setProperty8(getWindow(), cl[0] + '\0' + cl[1]);
                } finally {
                    XToolkit.awtUnlock();
                }
            }

        But the ICCCM specifies that unlike most window properties, which are not null
        terminated, the WM_CLASS is a special case that must be null terminated:

            Note that WM_CLASS strings are null-terminated and, thus, differ from the
            general conventions that STRING properties are null-separated.
            This inconsistency is necessary for backwards compatibility.

        (BTW, the error message for the IllegalArgumentException seems to have an extra
         "_NAME" on the end of the property name.)

          Activity

          Hide
          denis Denis Fokin (Inactive) added a comment -
          BT2:EVALUATION

          See the description.
          Show
          denis Denis Fokin (Inactive) added a comment - BT2:EVALUATION See the description.
          Hide
          hgupdate HG Updates added a comment -
          URL: http://hg.openjdk.java.net/jdk9/client/jdk/rev/82e20d566ab5
          User: omajid
          Date: 2015-12-29 15:43:56 +0000
          Show
          hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/client/jdk/rev/82e20d566ab5 User: omajid Date: 2015-12-29 15:43:56 +0000
          Hide
          hgupdate HG Updates added a comment -
          URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/82e20d566ab5
          User: lana
          Date: 2016-02-10 21:55:24 +0000
          Show
          hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/82e20d566ab5 User: lana Date: 2016-02-10 21:55:24 +0000

            People

            • Assignee:
              omajid Omair Majid
              Reporter:
              alanc Alan Coopersmith
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: