java-native-access / java-native-access/jna

Callback shouldn't be direct when CallbackProxy is used

Open
#315 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug? needs work
Dominant language
Java
Stars
8.9k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/com/sun/jna/CallbackReference.java and inspect the direct-mapping branch around the PPC check. Verify that callbacks implemented through CallbackProxy bypass direct mapping, and consider whether the PPC declaration belongs inside that branch as shown in the issue; done when the callback path reflects these changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.