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

Fix com4j event handling #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mgerhard-gk
Copy link

This commit fixes not always working com4j event handling. There are 2 issues fixed.

First is caused by a possible camelize of method names on event interface code generation. The camelize action is compliant with Java method naming conventions but native callback into EventProxy is not aware of such renaming of methods and fails to find the DISPID by name. To solve that a new annotation DISPNAME was introduced for storing the original method name. The EventInterfaceGenerator adds this annotation now to event methods besides the existing DISPID annotation. For keeping compatibility with existing code at runtime the DISPNAME is not mandatory for EventMethods. The EventInterfaceDescriptor uses the DISPNAME value (if present) or the Java method name (previous behavior) as key to fill the methodByName map.

The second is caused by a ComException on event method invoke and an arguments Variant.convertTo error. The exception is causing the JVM to crash with a access violation. To avoid that the event method args convertTo is wrapped by a try-catch now.

This commit fixes not always working com4j event handling. There are 2
issues fixed.

First is caused by a possible camelize of method names on event
interface code generation. The camelize action is compliant with Java
method naming conventions but native callback into EventProxy is not
aware of such renaming of methods and fails to find the DISPID by name.
To solve that a new annotation DISPNAME was introduced for storing the
original method name. The EventInterfaceGenerator adds this annotation
now to event methods besides the existing DISPID annotation. For keeping
compatibility with existing code at runtime the DISPNAME is not
mandatory for EventMethods. The EventInterfaceDescriptor uses the
DISPNAME value (if present) or the Java method name (previous behavior)
as key to fill the methodByName map.

The second is caused by a ComException on event method invoke and an
arguments Variant.convertTo error. The exception is causing the JVM to
crash with a access violation. To avoid that the event method args
convertTo is wrapped by a try-catch now.
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.

1 participant