Skip to content

Callback shouldn't be direct when CallbackProxy is used #315

Open
@marco2357

Description

@marco2357

If a callback is implemented through a CallbackProxy, it is probably a bad idea to allow it being called directly (bypassing the proxy).

diff --git a/src/com/sun/jna/CallbackReference.java b/src/com/sun/jna/CallbackReference.java
index bcf5568..5b15301 100644
--- a/src/com/sun/jna/CallbackReference.java
+++ b/src/com/sun/jna/CallbackReference.java
@@ -150,6 +150,7 @@
         // Check whether direct mapping may be used, or whether
         // we need to fall back to conventional mapping
         boolean ppc = Platform.isPPC();
+        if (callback instanceof CallbackProxy) direct = false;
         if (direct) {
             Method m = getCallbackMethod(callback);
             Class[] ptypes = m.getParameterTypes();

Also "boolean ppc = ...;" can be put into the "if (direct) {" block

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions