-
Bug
-
Resolution: Fixed
-
P3
-
16, 17, 18, 21, 22
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8353140 | 21.0.8 | Sergey Bylokhov | P3 | Resolved | Fixed | master |
Windows / Window 10/ JDK 16 and JDK 17ea
A DESCRIPTION OF THE PROBLEM :
Desktop.browse native peer implementation attempts to CoInitializeEx as COINIT_APARTMENTTHREADED and will fail if there has been a prior call (eg. via JNI) to CoInitialize as COINIT_MULTITHREADED. This problem is new in JDK 16/17ea - see awt_Desktop.cpp:88 in JDK source for point of failure.
REGRESSION : Last worked in version 15
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a native /JNI call that calls CoInitializeEx(NULL, COINIT_MULTITHREADED) and call the native prior to calling Dekstop.getDesktop().browse(url).
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
URL will open in system assigned browser (JDK 15 and earlier)
ACTUAL -
Exception in thread "main" java.io.IOException: Failed to open https://www.google.com. Error message: CoInitializeEx() failed.
at java.desktop/sun.awt.windows.WDesktopPeer.ShellExecute(WDesktopPeer.java:115)
at java.desktop/sun.awt.windows.WDesktopPeer.browse(WDesktopPeer.java:101)
at java.desktop/java.awt.Desktop.browse(Desktop.java:530)
....
---------- BEGIN SOURCE ----------
// approximate example cpp and java since not sure what is expected for
// a native/java bug test case
---- native ---
void Demo::initCom() {
HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
if (hr != S_FALSE)
EXIT_ON_ERROR(hr); // some sort of handling
}
-- java ---
public static void main(String [] args) throws URISyntaxException, IOException {
Demo.initCom();
Desktop desktop = Desktop.getDesktop();
desktop.browse(new URI("https://www.google.com"));
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
No workaround found.
FREQUENCY : always
- backported by
-
JDK-8353140 Desktop.browse method fails if earlier CoInitialize call as COINIT_MULTITHREADED
-
- Resolved
-
- caused by
-
JDK-6508941 java.awt.Desktop.open causes VM to crash with video files sporadically
-
- Resolved
-
- duplicates
-
JDK-8321317 Desktop.browse method fails
-
- Closed
-
- relates to
-
JDK-8321602 Create manual test for Desktop.browse with COINIT_MULTITHREADED
-
- Open
-
- links to
-
Commit openjdk/jdk/b25ed57b
-
Commit(master) openjdk/jdk21u-dev/5eb51cdc
-
Review openjdk/jdk/17010
-
Review(master) openjdk/jdk21u-dev/1543