United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7083825 revise the fix for 7074440
JDK-7083825 : revise the fix for 7074440

Details
Type:
Bug
Submit Date:
2011-08-26
Status:
Resolved
Updated Date:
2011-09-22
Project Name:
JDK
Resolved Date:
2011-09-06
Component:
deploy
OS:
windows_xp
Sub-Component:
plugin
CPU:
x86
Priority:
P3
Resolution:
Fixed
Affected Versions:
7-client
Fixed Versions:
7u2 (b04)

Related Reports
Backport:

Sub Tasks

Description
Current fix for 7074440 involves caching the dispid when CJavaDispatch::InvokeEx is called and then use the cached dispid later to setup the java name spaces.

Implementation is fragile because:
    a) There is no guarantee IE will always perform any calls back to CJavaDispatch after registration
         (and then we may do something wrong on first real PROPERTYPUT)
    b) There is no guarantee there will be just one call from IE after we register object
    c) First real use of CJavaObject may also be PROPERTYPUT and then we may mistakenly ignore it.

                                    

Comments
EVALUATION

I found that CJavaDispatch::InvokeEx only gets called from AxControl::SetClientSite if the html file contains the DOCTYPE as in the following test case:
http://oklahoma.us.oracle.com/www/tests/7-client/7074440/test.html

When CJavaDispatch::InvokeEx is called for each of the java namespace,
    dispid = 0
    wFlags = 2 (DISPATCH_PROPERTYGET)
    VARIANTARGS* (pdp->rgvarg) is NULL

With the current fix:
    if (targetObject == NULL && javaNameSpace != NULL) {
        // if it's for setting up the java name space property
        // temporary stores the dispatch id since the plugin object
        // may not have been initialized at this point.
        if (wFlags & DISPATCH_PROPERTYPUT) {
            SetJavaNameSpaceDispid(dispid);
            return S_OK;
        } else {
            // GetJavaPluginInstance() also sets java name space at the java level
            // if necessary. Once a dispid is set, it'll be reused at subsequent times
            // when the same name is encountered.
            // Attempt to fetch the JavaNameSpace object corresponding to this namespace
            targetObject = AbstractPlugin::getJavaNameSpace(GetJavaPluginInstance(),
                                                            javaNameSpace);
        }
    }

it won't call SetJavaNameSpaceDispid(dispid) but will go to the else branch.
Within GetJavaPluginInstance(), it'll wait for pluginObject is ready before returning and won't call AbstractPlugin::javaObjectSetField() since bNeedToProcessJavaNameSpace is false.
CJavaDispatch::GetIDsOfNames wasn't called with the testcase.

I've tried the following condition check in CJavaDispatch::InvokeEx and it seems working and I don't see any side-effect with IE8 so far:

    if (targetObject == NULL && javaNameSpace != NULL) {
        if ((dispid == 0) && (wFlags & DISPATCH_PROPERTYGET)) {
            return DISP_E_MEMBERNOTFOUND;
        }

       ...
   }

The only time I observed ((dispid == 0) && (wFlags & DISPATCH_PROPERTYGET)) is when javascript trying to instantiate a java object such as "new java.lang.Integer(2)" but targetObject won't be null because it'll be set when CJavaDispatch::GetIDsOfNames is called.

btw, with IE8 with the same testcase, CJavaDispatch::InvokeEx won't be called when setting up the java name space. It's also the case if I remove the "DOCTYPE" line in the html file and run the testcase with IE9.

From Igor:
-----------
According to the Windows include file OAIDL.H:

/* DISPID reserved for the "value" property */
#define    DISPID_VALUE    ( 0 )

According to the help for DISPID, DISPID_VALUE is :

"The default member for the object. This property or method is invoked
when an ActiveX client specifies the object name without a property or
method."

Other help topics for DISPID_VALUE state:

* An object is coerced to a value by invoking the object's Value
property (DISPID_VALUE).

* The Value property defines the default behavior of an object when no
property or method is specified. It is typically used for the property
that users associate most closely with the object. 

From Alexey:
-----------
Default value make sense just for VB event model (name-based event handling).
In our case it is useless.
                                     
2011-08-26



Hardware and Software, Engineered to Work Together