Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 433400 - SWT Snippet308 fails with IBM JRE
Summary: SWT Snippet308 fails with IBM JRE
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.4   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 4.4 RC1   Edit
Assignee: Niraj Modi CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-04-24 08:41 EDT by Akihiko Takajo CLA
Modified: 2014-05-12 01:30 EDT (History)
7 users (show)

See Also:
grant_gayed: review+


Attachments
patch (1.63 KB, patch)
2014-05-08 16:50 EDT, Grant Gayed CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Akihiko Takajo CLA 2014-04-24 08:41:03 EDT
org.eclipse.swt.snippets.Snippet308.java fails with IBM JRE.
It works with Oracle JRE.

Environment:
OS: Windows 7 Japanese
java version "1.7.0"
 Java(TM) SE Runtime Environment (build pwa6470_27-20131115_04)
 IBM J9 VM (build 2.7, JRE 1.7.0 Windows 7 amd64-64 Compressed References 20131114_175264 (JIT enabled, AOT enabled)
SWT: org.eclipse.swt.win32.win32.x86_64_3.103.0.v20140305-1110.jar


Console:
=======
Exception in thread "main" org.eclipse.swt.SWTException: Undefined or NULL 参照のプロパティ 'childNodes' は取得できません
	at org.eclipse.swt.browser.WebBrowser$EvaluateFunction.function(WebBrowser.java:192)
	at org.eclipse.swt.browser.WebSite.Invoke(WebSite.java:774)
	at org.eclipse.swt.browser.WebSite$7.method6(WebSite.java:130)
	at org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:119)
	at org.eclipse.swt.internal.ole.win32.COM.VtblCall(Native Method)
	at org.eclipse.swt.internal.ole.win32.IDispatch.Invoke(IDispatch.java:64)
	at org.eclipse.swt.ole.win32.OleAutomation.invoke(OleAutomation.java:571)
	at org.eclipse.swt.ole.win32.OleAutomation.invoke(OleAutomation.java:534)
	at org.eclipse.swt.browser.IE.execute(IE.java:1157)
	at org.eclipse.swt.browser.WebBrowser.evaluate(WebBrowser.java:434)
	at org.eclipse.swt.browser.Browser.evaluate(Browser.java:614)
	at org.eclipse.swt.snippets.Snippet308$1.completed(Snippet308.java:46)
	at org.eclipse.swt.browser.IE$7.handleEvent(IE.java:628)
	at org.eclipse.swt.ole.win32.OleEventTable.sendEvent(OleEventTable.java:55)
	at org.eclipse.swt.ole.win32.OleEventSink.notifyListener(OleEventSink.java:152)
	at org.eclipse.swt.ole.win32.OleEventSink.Invoke(OleEventSink.java:120)
	at org.eclipse.swt.ole.win32.OleEventSink.access$1(OleEventSink.java:97)
	at org.eclipse.swt.ole.win32.OleEventSink$1.method6(OleEventSink.java:71)
	at org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:119)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2549)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3759)
	at org.eclipse.swt.snippets.Snippet308.main(Snippet308.java:54)
Comment 1 Akihiko Takajo CLA 2014-04-24 08:43:57 EDT
IES4.4 build: I20140423-1600
Comment 2 Niraj Modi CLA 2014-05-05 03:22:29 EDT
Hi Akihiko,
Facing similar error with IBM 64bit JDK @ Windows with English:
Unable to get property 'childNodes' of undefined or null reference.

But, Snippet308 works with IBM 32bit JDK @ Win7-English.
Can you try if it works for you with IBM 32bit JDK ?
Comment 3 Akihiko Takajo CLA 2014-05-05 05:01:15 EDT
Hi Niraj,
I tried with 32 bit IBM JDK and verified it works on Japanese Windows.
Comment 4 Niraj Modi CLA 2014-05-05 08:24:36 EDT
(In reply to Akihiko Takajo from comment #3)
> Hi Niraj,
> I tried with 32 bit IBM JDK and verified it works on Japanese Windows.

Thanks Akihiko, for the confirmation on this.

Snippet308 works fine with Oracle-64bit/32bit & IBM 32bit JDKs with Japanese/non-Japanese locales.
Snippet308 fails only with IBM 64bit JDK(non-Japanese locales as well), so this issue doesn't seems specific to handling of DBCS characters with SWT as such.
Closing this bug from SWT side, please raise a defect against IBM 64bit JDK/JRE.
Comment 5 Grant Gayed CLA 2014-05-05 10:12:39 EDT
(In reply to Niraj Modi from comment #4)

To clarify, what's happening here is the same as https://bugs.eclipse.org/bugs/show_bug.cgi?id=343550#c6 .  For some reason the Browser gets 1+ extra DocumentCompleted events when the 64-bit IBM JRE is used, and this makes Snippet308 fail because an unexpected DocumentCompleted event comes before the native browser's DOM has been built (so it's too early to ask it for element 'myId').  If this value is queried on the second received 'completed' event then it works (but of course this second event never comes with the other JREs, nor should it).

I'm not 100% sure that it's an IBM JRE problem, but it definitely could be.  I meant to investigate this further with bug 343550 to get a more definitive conclusion but never did.  Having this Snippet308 case is helpful because it provides a more straight-forward test case than bug 343550.  Niraj if a report is to be logged with the VM group then they will need a reduced stand-alone snippet (ie.- not all of swt, just the relevant parts of its COM and OLE implementations) that demonstrates the extra event being received.
Comment 6 Niraj Modi CLA 2014-05-07 05:55:12 EDT
(In reply to Grant Gayed from comment #5)

Thanks for these pointers Grant.
Able to work-around that unexpected document complete event with IBM 64bit JVM on SWT side, by detecting that premature document complete event based on document.readyState value{which can be null, 'uninitialized', 'loading', 'interactive', 'complete'}
On IBM 64bit JVM with IE, SWT is throwing the document complete event even when the document.readyState value is 'loading' and Snippet308 ends up interacting with an incomplete browser content.
Filtered-out that event in IE class, refer below Gerrit patch:
https://git.eclipse.org/r/#/c/26098/

Note:-
Snippet308 with Mozilla, SWT is throwing document complete events for 'interactive' and 'complete' values of document.readyState, and Snippet308 works fine in either case.
For issue in IBM 64bit JVM, we could further investigate @ bug 343550
Comment 7 Grant Gayed CLA 2014-05-08 16:50:09 EDT
Created attachment 242872 [details]
patch

It would be better to not cross the Java/JS boundary to evaluate this each time.  The attached patch does this.

One additional thought: My patch includes the INTERACTIVE case as one where the event is sent, because the original patch also included this case, and because the potential scenario of sending no DocumentComplete events is worse than the scenario of sending two events if the two both come late enough that the DOM is ready.  However, ideally only one DocumentComplete event should be sent, so if your testing indicates that one of these ALWAYS comes when the COMPLETED state is reached then the INTERACTIVE case can likely be removed from sending DocumentComplete.
Comment 8 Niraj Modi CLA 2014-05-09 03:32:22 EDT
(In reply to Grant Gayed from comment #7)
> Created attachment 242872 [details]

Updated the patch after above inputs. Also tested for INTERACTIVE case, it doesn't looks mandatory since we reach COMPLETED state finally, hence removed:
https://git.eclipse.org/r/#/c/26098/
Comment 9 Grant Gayed CLA 2014-05-09 11:48:33 EDT
The comment 8 change looks good.
Comment 10 Arun Thondapu CLA 2014-05-09 12:01:01 EDT
(In reply to Grant Gayed from comment #9)
> The comment 8 change looks good.

Thanks for the review Grant! Pushed the patch to master - http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=0658d789bfb0cb2ccab2ad6b8af953cadf626c1e
Comment 11 Akihiko Takajo CLA 2014-05-12 01:30:27 EDT
verified with I20140511-2000.
Thanks,