JDK-6790710 : IE hangs up when the mouse is clicked outside of IE
  • Type: Bug
  • Component: deploy
  • Sub-Component: plugin
  • Affected Version: 6u10
  • Priority: P3
  • Status: Resolved
  • Resolution: Won't Fix
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2009-01-06
  • Updated: 2017-12-22
  • Resolved: 2017-12-22
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
Java(TM) SE Runtime Environment (build 1.6.0_12-ea-b02)


ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]


A DESCRIPTION OF THE PROBLEM :
The browser hangs up when a modal dialog is popped up througth an applet through a Javascript.
It hangs up when next generation's Java Plug-in is checked with the Java control panel. However, the problem doesn't occur if next generation's Java Plug-in is not checked.
Then, it is thought that this is trouble of next generation's Java Plug-in.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
- Compile Test.java JniDll.java(javac *.java)
- Make Jni header file(javah -classpath . JniDll)
- Using VisualStudio2008 and make JniDll.dll
- .java.policy allow permission
http://xxxxxx/- {
   permission java.util.PropertyPermission "user.dir", "read";
   permission java.lang.RuntimePermission "loadLibrary.JniDll";
};
- Click on the html "ReadNative" button
- A filedialog pops up. Click autoside of the browser.The browse hangs.



REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
-- Test.java --
import java.security.AccessController;
import java.security.PrivilegedAction;
import javax.swing.JApplet;
import javax.swing.JFileChooser;

public class Test extends JApplet {
    protected final void openDialog() {
      JFileChooser fc = new JFileChooser();
      fc.showOpenDialog(this);
    }
    protected final void openJniDialog() {
       JniDll.canLoadDll();
       JniDll jni = new JniDll();
       jni.open("");
    }
    public void open() {
      AccessController.doPrivileged(new PrivilegedAction() {
        public Object run() {
          openDialog();
          return null;
        }
      });
    }
    public void open2() {
      AccessController.doPrivileged(new PrivilegedAction() {
        public Object run() {
          openJniDialog();
          return null;
        }
      });
    }
}
-- JniDll.java --
public class JniDll {
    
    private static final String LOAD_DLL_NAME = "JniDll";
    
    private static boolean isDllLoadOk = false;
    
    private static boolean yetDllLoad = false;
    
    public native String open(String initPath);
    
    /**
     */
    public static boolean canLoadDll() {
        
        if (!yetDllLoad) {
            yetDllLoad = true;
            try {
                System.loadLibrary(LOAD_DLL_NAME);
                isDllLoadOk = true;
            }
            catch (java.lang.UnsatisfiedLinkError e) {
                e.printStackTrace();
                return false;
            }
        }
        return isDllLoadOk;
    }
}
-- Test.html --
<html>
<head>
  <title>Test</title>
</head>
<script type="text/javascript">
function opendlg() {
  document.app1.open();
}
function opendlg2() {
  document.app1.open2();

}
</script>
<body>
<applet id="app1"
  code="Test" width="0" height="0">
</applet>
<hr>
<form>
<input type="button" value="Read"
  width="50" height="50"
  onClick="javascript:opendlg()">
<br>
<input type="button" value="ReadNative"
  width="50" height="50"
  onClick="javascript:opendlg2()">
</form>
</body>
</html>
-- JniDll.cpp --
#include "stdafx.h"

#define MAX_BUF_SIZE 4096

/*
* jstring to SJIS
*/
char * jstring2sjis(JNIEnv *env, jstring jstr) {

    if (jstr == NULL) {
        return NULL;
    }

    const jchar* mbstr = env->GetStringChars(jstr, NULL);

    int nLen = WideCharToMultiByte(CP_ACP,
        0, (LPCWSTR)mbstr, -1, NULL, 0, NULL, NULL);
    char *lpszW = new char[nLen];
    memset(lpszW, '\0', nLen);

    WideCharToMultiByte(CP_ACP,
        0, (LPCWSTR)mbstr, -1, lpszW, nLen, NULL, NULL);

    env->ReleaseStringChars(jstr, mbstr);

    return lpszW;
}

/*
* SJIS to jstring
*/
jstring sjis2jstring(JNIEnv *env, char * path) {

    int uLen = MultiByteToWideChar(CP_ACP,
        0,path, strlen(path), NULL, 0);

    WCHAR *retBuff = new WCHAR[uLen];
    MultiByteToWideChar(CP_ACP,
        0, path, strlen(path), retBuff, uLen);

    jstring ret = env->NewString((jchar *)retBuff , uLen);

    delete retBuff;

    return ret;
}

/*
 * open file daialog
 */
JNIEXPORT jstring JNICALL  Java_JniDll_open
(JNIEnv *env, jobject obj, jstring jstr) {

    char * lpstrInitalDir = jstring2sjis(env, jstr);

    char path[MAX_BUF_SIZE];
    memset(path,'\0',sizeof(path));
    OPENFILENAME OFN;
    ZeroMemory(&OFN,sizeof(OPENFILENAME));
    OFN.lStructSize       = sizeof(OPENFILENAME);
    OFN.hwndOwner         = GetForegroundWindow();
    OFN.hInstance         = NULL;
    OFN.lpstrFilter       = NULL; //(LPCWSTR)"xml(*.xml)\0*.xml\0";
    OFN.lpstrCustomFilter = NULL;
    OFN.nMaxCustFilter    = NULL;
    OFN.nFilterIndex      = 0;
    OFN.lpstrFile         = (LPWSTR)path;
    OFN.nMaxFile          = sizeof(path);
    OFN.lpstrFileTitle    = NULL;
    OFN.nMaxFileTitle     = NULL;
    OFN.lpstrInitialDir   = (LPCWSTR)lpstrInitalDir;
    OFN.lpstrTitle        = NULL;
    OFN.Flags             = OFN_FILEMUSTEXIST|OFN_HIDEREADONLY|OFN_LONGNAMES;
    OFN.nFileOffset       = 0;
    OFN.nFileExtension    = NULL;

    jstring result = NULL;
    if (GetOpenFileName(&OFN)) {
        result = sjis2jstring(env, path);
    }

    if (lpstrInitalDir != NULL) {
        delete lpstrInitalDir;
    }

    return result;
}

---------- END SOURCE ----------

SUPPORT :
YES

Release Regression From : 6u7
The above release value was the last known release where this 
bug was not reproducible. Since then there has been a regression.

Comments
EVALUATION Note that we must only pump input messages in limited situations, in particular when a dialog has been raised, to avoid regressions like 6647406.
30-01-2009

EVALUATION The testcase consists of 2 scenarios: 1) javascript calls into applet and pops up a java file chooser dialog; 2) javascript calls into applet which calls a function in a dll to pop up a windows file dialog. Only the second scenario hangs the browser occasionally with JRE 6u14 nightly build. Since the applet calls into a native method to pop up a dialog in the second case, the plugin modality listener doesn't know that there's a dialog and doesn't set the "isModalDialogActive" flag to true when calling the runMessagePump method. A fix will need to be at the native level to detect if there's a native dialog and set the event mask accordingly. Setting the event mask to always include PM_QS_INPUT in the runMessagePump native method seems to have fixed the problem. More investigation is needed to ensure that including the PM_QS_INPUT event mask doesn't have other side-effects.
30-01-2009