United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7103610 _NET_WM_PID and WM_CLIENT_MACHINE are not set
JDK-7103610 : _NET_WM_PID and WM_CLIENT_MACHINE are not set

Details
Type:
Bug
Submit Date:
2011-10-21
Status:
Resolved
Updated Date:
2012-06-07
Project Name:
JDK
Resolved Date:
2011-12-14
Component:
client-libs
OS:
linux_ubuntu,linux
Sub-Component:
java.awt
CPU:
x86
Priority:
P4
Resolution:
Fixed
Affected Versions:
p1.0,7
Fixed Versions:

Related Reports
Backport:

Sub Tasks

Description
FULL PRODUCT VERSION :
java version "1.7.0"
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) 64-Bit Server VM (build 21.0-b17, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
Ubuntu 11.10
Linux 3.0.0-12-generic #20-Ubuntu SMP Fri Oct 7 14:56:25 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux


EXTRA RELEVANT SYSTEM CONFIGURATION :
gnome3 with gnome-shell as desktop environment

A DESCRIPTION OF THE PROBLEM :
The X-Window properties _NET_WM_PID and WM_CLIENT_MACHINE and WM_CLASS of X11 are not set when opening windows (e.g. JFrame) on jre 1.7.0 or jdk 1.7.0 .

This leads especially to strange behaviour with gnome-shell application switcher, the windows of one java application are not grouped together, and for TrayIcon, which will is not displayed depend on this properties correctly set.


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Starting java applications with multiple windows in one application (like netbeans) in gnome3/gnome-shell as desktop environment.



EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The application switcher of gnome-shell (ALT-TAB) shows just one entry for all windows of the same application.

ACTUAL -
The application switcher of gnome-shell (ALT-TAB) shows multiple entries in the gnome application-switcher (ALT-TAB).
A Tray Icon won't show up in the system tray at the bottom.


REPRODUCIBILITY :
This bug can be reproduced always.

                                    

Comments
EVALUATION

Contributed fix: http://mail.openjdk.java.net/pipermail/awt-dev/2011-October/001951.html

It has some issues with retrieving the PID and FQDN, this is currently being discussed on the mailing list.
                                     
2011-10-24
EVALUATION

http://hg.openjdk.java.net/jdk8/awt/jdk/rev/f614bcada2a9
                                     
2011-11-11
SUGGESTED FIX

--- a/make/sun/xawt/mapfile-vers	Thu Nov 10 17:37:29 2011 +0400
+++ b/make/sun/xawt/mapfile-vers	Fri Nov 11 15:17:51 2011 +0300
@@ -322,6 +322,8 @@ SUNWprivate_1.1 {
         Java_sun_awt_X11_XlibWrapper_XSynchronize;
         Java_java_awt_FileDialog_initIDs;
         Java_sun_awt_X11_XWindow_initIDs;
+        Java_sun_awt_X11_XWindowPeer_getLocalHostname;
+        Java_sun_awt_X11_XWindowPeer_getJvmPID;
 
         Java_sun_java2d_opengl_OGLContext_getOGLIdString;
         Java_sun_java2d_opengl_OGLMaskFill_maskFill;
--- a/src/solaris/classes/sun/awt/X11/XWindowPeer.java	Thu Nov 10 17:37:29 2011 +0400
+++ b/src/solaris/classes/sun/awt/X11/XWindowPeer.java	Fri Nov 11 15:17:51 2011 +0300
@@ -208,11 +208,18 @@ class XWindowPeer extends XPanelPeer imp
         return name;
     }
 
+    private static native String getLocalHostname();
+    private static native int getJvmPID();
+
     void postInit(XCreateWindowParams params) {
         super.postInit(params);
 
         // Init WM_PROTOCOLS atom
         initWMProtocols();
+
+        // Set _NET_WM_PID and WM_CLIENT_MACHINE using this JVM
+        XAtom.get("WM_CLIENT_MACHINE").setProperty(getWindow(), getLocalHostname());
+        XAtom.get("_NET_WM_PID").setCard32Property(getWindow(), getJvmPID());
 
         // Set WM_TRANSIENT_FOR and group_leader
         Window t_window = (Window)target;
--- a/src/solaris/native/sun/xawt/XToolkit.c	Thu Nov 10 17:37:29 2011 +0400
+++ b/src/solaris/native/sun/xawt/XToolkit.c	Fri Nov 11 15:17:51 2011 +0300
@@ -46,6 +46,8 @@
 #include "java_awt_SystemColor.h"
 #include "java_awt_TrayIcon.h"
 #include <X11/extensions/XTest.h>
+
+#include <unistd.h>
 
 uint32_t awt_NumLockMask = 0;
 Boolean  awt_ModLockIsShiftLock = False;
@@ -1087,3 +1089,38 @@ int32_t getNumButtons() {
 
     return local_num_buttons;
 }
+
+/*
+ * Class:     sun_awt_X11_XWindowPeer
+ * Method:    getJvmPID
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_sun_awt_X11_XWindowPeer_getJvmPID
+(JNIEnv *env, jclass cls)
+{
+    /* Return the JVM's PID. */
+    return getpid();
+}
+
+#ifndef HOST_NAME_MAX
+#define HOST_NAME_MAX 1024 /* Overestimated */
+#endif
+
+/*
+ * Class:     sun_awt_X11_XWindowPeer
+ * Method:    getLocalHostname
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_sun_awt_X11_XWindowPeer_getLocalHostname
+(JNIEnv *env, jclass cls)
+{
+    /* Return the machine's FQDN. */
+    char hostname[HOST_NAME_MAX + 1];
+    if (gethostname(hostname, HOST_NAME_MAX + 1) == 0) {
+        hostname[HOST_NAME_MAX] = '\0';
+        jstring res = (*env)->NewStringUTF(env, hostname);
+        return res;
+    }
+
+    return (jstring)NULL;
+}
                                     
2011-11-16



Hardware and Software, Engineered to Work Together