Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow access to base interfaces via ProxyObject and improve binding #616

Conversation

matthiasblaesing
Copy link
Member

The ProxyObject implements several base interfaces directly, but the methods were not correctly handled. This pull modifies the InvocationHandler part to select methods based on declaration interface with direct method invocation, instead of manually redirecting each method.

The second part adds more robustness (and speed as sideeffect) to ProxyObject by using dispIDs if they are available, making reflection via GetIDsByName unnessary.

Although the ProxyObject by definition exposes a IDispatch, the methods
are not callable via the Proxy.
…etIDsOfNames)

dispIDs can be queried via GetIDsOfNames at runtime or retrieved from the
typelibrary when bindings are generated.

Using the dispID eliminates one additional call into native environment.

It was also observed, that runtime reflection sometimes retrieves wrong
values (toString on IHTMLDocument2), so using a previously retrieved value
seems to be saver.
@matthiasblaesing matthiasblaesing force-pushed the c.s.j.p.w.COM.util_access_IDispatch branch from 1714d29 to b57fe09 Compare March 11, 2016 20:50
@@ -43,6 +43,7 @@ Features
* [#608](https://github.com/java-native-access/jna/pull/608): Mavenize the build process - change parent and native pom artifactId/name to differentiate in IDE and build tools. [@bhamail](https://github.com/bhamail)
* [#613](https://github.com/java-native-access/jna/pull/613): Make Win32Exception extend LastErrorException [@lgoldstein](https://github.com/lgoldstein).
* [#613](https://github.com/java-native-access/jna/pull/614): Added standard 'Kernel32Util#closeHandle' method that throws a Win32Exception if failed to close the handle [@lgoldstein](https://github.com/lgoldstein).
* [#616](https://github.com/java-native-access/jna/pull/616): Allow access to base interfaces (most important IDispatch) via ProxyObject and improve binding by allowing to use dispId for the call [@matthiasblaesing](https://github.com/matthiasblaesing)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing period at the end ;)

@dblock
Copy link
Member

dblock commented Mar 13, 2016

This looks ok to me, maybe @lgoldstein could help with a more thorough CR, I don't understand half the code ;)

@matthiasblaesing matthiasblaesing force-pushed the c.s.j.p.w.COM.util_access_IDispatch branch from b57fe09 to a1bee93 Compare March 25, 2016 22:14
@matthiasblaesing
Copy link
Member Author

The CHANGES.md entry was adjusted - is there any way I can help with review?

@dblock
Copy link
Member

dblock commented Mar 26, 2016

I'll mege.

@dblock dblock merged commit 2c6d9e8 into java-native-access:master Mar 26, 2016
@matthiasblaesing matthiasblaesing deleted the c.s.j.p.w.COM.util_access_IDispatch branch March 30, 2016 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants