JDK-6419042 : JCK-runtime-60: api/java_awt/interactive/SystemTrayTests.html fail on Windows Vista 32 IE7.0 Plugin
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_vista
  • CPU: x86
  • Submitted: 2006-04-27
  • Updated: 2012-03-22
  • Resolved: 2007-03-28
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 JDK 7 Other
6u2 b01Fixed 7Resolved OpenJDK6Fixed
Related Reports
Relates :  
Description
JCK            : JCK6.0 b22
J2SE           : FAIL - mustang b80
Platform[s]    : FAIL - Windows Vista 32 beta2
		 PASS - Windows XP Pro 32
switch/Mode    : FAIL - default

Test fails only under Plugin.

Failed testcases:
----------------------
api/java_awt/interactive/SystemTrayTests.html#SystemTrayTests

jtr file location:
=================================
attached

how to reproduce:
=================================
Compile this applet and open it using IE7.0 on the Windows Vista 32 machine - tray icon doesn't appear. If you open it on WinXP - tray icon appears.

    import java.awt.*;
    import java.net.*;
    import java.io.*;

    public class BallTest extends java.applet.Applet {
        public void start() {
            try {
                Image image = Toolkit.getDefaultToolkit().getImage(
                        new URL("file:///C:/temp/12321/blue-ball.gif")); /* put your path here */
            } catch (Exception e) {
                throw new RuntimeException(e.getMessage());
            }
            TrayIcon trayIcon = new TrayIcon(image, "System Tray Test");
            trayIcon.setImageAutoSize(true); 
	        try {
	          SystemTray systemTray = SystemTray.getSystemTray();
	          systemTray.add(trayIcon);
                } catch (Exception e2) {}
        }
        public void stop() {}
    }

Comments
SUGGESTED FIX *** /net/awt64-1/export2/dc158259/ws/jdk6u1/webrev/src/windows/native/sun/windows/awt_Toolkit.cpp- Thu Nov 30 20:29:30 2006 --- awt_Toolkit.cpp Thu Nov 30 20:29:14 2006 *************** *** 2312,2321 **** --- 2312,2363 ---- return (newEventNumber - eventNumber) > 2; } } /* extern "C" */ + /* + * Class: sun_awt_windows_WToolkit + * Method: isProtectedMode + * Signature: ()Z + */ + JNIEXPORT jboolean JNICALL + Java_sun_awt_windows_WToolkit_isProtectedMode(JNIEnv *env, jclass cls) + { + TRY; + + if (!IS_WINVISTA) { + return JNI_FALSE; + } + + BOOL bIEIsProtectedModeProcess; + HINSTANCE hLibIEFrameDll = ::LoadLibrary(TEXT("IEFRAME.DLL")); + + typedef HRESULT IEIsProtectedModeProcessFunc(BOOL *); + + if (hLibIEFrameDll != NULL) + { + IEIsProtectedModeProcessFunc *lpIEIsProtectedModeProcess = + (IEIsProtectedModeProcessFunc*)GetProcAddress(hLibIEFrameDll, + "IEIsProtectedModeProcess"); + + HRESULT hResult; + if (lpIEIsProtectedModeProcess != NULL) { + hResult = lpIEIsProtectedModeProcess(&bIEIsProtectedModeProcess); + } + + ::FreeLibrary(hLibIEFrameDll); + + if (SUCCEEDED(hResult) && bIEIsProtectedModeProcess) { + return JNI_TRUE; + } + } + + return JNI_FALSE; + + CATCH_BAD_ALLOC_RET(JNI_FALSE); + } + /* Convert a Windows desktop color index into an RGB value. */ COLORREF DesktopColor2RGB(int colorIndex) { DWORD sysColor = ::GetSysColor(colorIndex); return ((GetRValue(sysColor)<<16) | (GetGValue(sysColor)<<8) | (GetBValue(sysColor)) | 0xff000000); *** /net/awt64-1/export2/dc158259/ws/jdk6u1/webrev/src/windows/classes/sun/awt/windows/WToolkit.java- Thu Nov 30 20:29:29 2006 --- WToolkit.java Thu Nov 30 20:20:39 2006 *************** *** 483,493 **** --- 483,497 ---- public SystemTrayPeer createSystemTray(SystemTray target) { return new WSystemTrayPeer(target); } + // workaround for 6419042 public boolean isTraySupported() { + if (isProtectedMode()) { + return false; + } return true; } protected native void setDynamicLayoutNative(boolean b); *************** *** 1000,1006 **** --- 1004,1011 ---- public DesktopPeer createDesktopPeer(Desktop target) { return new WDesktopPeer(); } + private static native boolean isProtectedMode(); }
05-12-2006

EVALUATION As it was mentioned before, Microsoft suggested us to use LoadLibrary + GetProcAddress to resolve this issue. However, it didn't help (tested on Vista6000). I tried to use profiling feature in depends.exe tool to verify if LoadLibrary+GetProcAddr works on our patched build. But for some reasons dependency walker does not detect the dynamic dependency in our code. So LoadLibrary + GetProcAddress is not enough to guarantee that shimming mechanism catches us. It's not clear what else we need to do for this. We have following workaround for this issue. TrayIcon API will not be supported in case of Applet mode / IE7 Protected mode / Vista. Diffs for the workaround can be found at 'suggested fix' section. We are using Vista-specific function IEIsProtectedModeProcess to determine if Microsoft Internet Explorer is running in protected mode. In stand-alone mode we expect that the IEIsProtectedModeProcess function fails with error code - ERROR_CLASS_DOES_NOT_EXIST. So the patch won't change behavior outside Applet mode.
05-12-2006

EVALUATION The bug in Vista has been fixed recently but the bug in AWT still exists. TrayIcon doesn't work on IE7 with enabled protected mode. The problem is that awt.dll link unicode API functions with unicows.lib (and Shell_NotifyIconW among them). But unicows doesn't go through the import table so it bypasses Microsoft shimming mechanism. We can't link with shell32.lib, because awt will fail on Win95. To resolve this issue Microsoft suggested to call LoadLibrary + GetProcAddress. We tried this but the problem isn't gone. Currently we are going to include this patch in a update release of JDK6.0.
14-09-2006

EVALUATION It's a bug in Vista. We call Shell_NotifyIcon directly from our code directly to display a icon in the system tray. In XP, running with a standard user, this works and Shell_NotifyIcon return true. In Vista and IE protected mode, this fail and Shell_NotifyIcon return false. If we run IE elevated, it works. Here is the reply from the MS engineer: "In terms of Shell_NotifyIcon, this is broken by a security tightening. We need brainstorming the solution. The problem is that IE in Vista will run at MIC integrity level low. The shell runs at medium. Low is not allowed to send message to medium. Under the hook, Shell_NotifyIcon sends message." "It was fixed in 4/5/06 in our private branch. It didn't make into the beta 2. If you have the access to latest RC1 build, you should be able to verify the fix." We will verify this as soon as we have access to the build with the fix. Please look at the comment section for detailed information.
27-04-2006