diff --git a/CHANGES.md b/CHANGES.md index 7be58366a2..2ed375efe2 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,6 +7,7 @@ Release 5.0.0 (Next release) Features -------- +* [#903](https://github.com/java-native-access/jna/pull/903): Carry `HRESULT` in `c.s.j.p.win32.COM.COMException`, introduce `c.s.j.p.win32.COM.COMInvokeException` as subclass of `COMException` for exception as the result of a `IDispatch#Invoke`. The `EXECPINFO` is unwrapped into fields in the `COMInvokeException` and correctly freed. - [@matthiasblaesing](https://github.com/matthiasblaesing). * [#822](https://github.com/java-native-access/jna/issues/822): `Native#loadLibrary` requires that the interface class passed in is an instance of Library. The runtime check can be enhanced by using a constraint generic. This breaks binary compatibility (see notes below) - [@d-noll](https://github.com/d-noll). * [#889](https://github.com/java-native-access/jna/issues/889): The `Structure#newInstance` receive the target type as a parameter. This adds a limited generic type, so that the return type ist the target type and not a generic structure, removing the necessity to do an explizit cast - [@matthiasblaesing](https://github.com/matthiasblaesing). @@ -69,6 +70,9 @@ Breaking Changes * `com.sun.jna.platform.win32.Kernel32Util.formatMessageFromHR(HRESULT)` was replaced by `com.sun.jna.platform.win32.Kernel32Util.formatMessage(HRESULT)` +* `com.sun.jna.platform.win32.COM.COMException` was structurally modified. The + `pExcepInfo` and `puArgErr` members were removed and `hresult` member was added. + The now missing information in `COMException` was moved to `COMInvokeException`. Release 4.5.0 ============= diff --git a/contrib/msoffice/src/com/sun/jna/platform/win32/COM/office/MSOfficeDemo.java b/contrib/msoffice/src/com/sun/jna/platform/win32/COM/office/MSOfficeDemo.java index 3230182654..372aa0df40 100644 --- a/contrib/msoffice/src/com/sun/jna/platform/win32/COM/office/MSOfficeDemo.java +++ b/contrib/msoffice/src/com/sun/jna/platform/win32/COM/office/MSOfficeDemo.java @@ -26,6 +26,7 @@ import com.sun.jna.Pointer; import com.sun.jna.platform.win32.COM.COMException; +import com.sun.jna.platform.win32.COM.COMInvokeException; import com.sun.jna.platform.win32.COM.Helper; import com.sun.jna.platform.win32.Ole32; import com.sun.jna.platform.win32.WinDef.LONG; @@ -102,11 +103,10 @@ public void testMSWord() throws IOException { msWord.insertText("Hello some changes from JNA!\n"); // save the document and prompt the user msWord.Save(false, wdPromptUser); + } catch (COMInvokeException e) { + System.out.println("bstrSource: " + e.getSource()); + System.out.println("bstrDescription: " + e.getDescription()); } catch (COMException e) { - if (e.getExcepInfo() != null) { - System.out.println("bstrSource: " + e.getExcepInfo().bstrSource); - System.out.println("bstrDescription: " + e.getExcepInfo().bstrDescription); - } } finally { if (msWord != null) { msWord.quit();