From 6731831fa29b392ba4201ffc8802628635e64edd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Bl=C3=A4sing?= Date: Sun, 7 Jan 2018 11:14:37 +0100 Subject: [PATCH] Add COMException changes to CHANGES.md and adjust msoffice demo to follow the changes --- CHANGES.md | 4 ++++ .../sun/jna/platform/win32/COM/office/MSOfficeDemo.java | 8 +++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index a8d0f9858c..d3a560b22d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,6 +7,7 @@ Release 5.0.0 (Next release) Features -------- +* [#???](https://github.com/java-native-access/jna/pull/???): 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). Bug Fixes --------- @@ -67,6 +68,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..20464646d3 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; @@ -103,9 +104,10 @@ public void testMSWord() throws IOException { // save the document and prompt the user msWord.Save(false, wdPromptUser); } catch (COMException e) { - if (e.getExcepInfo() != null) { - System.out.println("bstrSource: " + e.getExcepInfo().bstrSource); - System.out.println("bstrDescription: " + e.getExcepInfo().bstrDescription); + if (e instanceof COMInvokeException) { + COMInvokeException cie = (COMInvokeException) e; + System.out.println("bstrSource: " + cie.getSource()); + System.out.println("bstrDescription: " + cie.getDescription()); } } finally { if (msWord != null) {