Skip to content

Commit

Permalink
Writing a callback fails, as it tries to create a SAFEARRAY with a ze…
Browse files Browse the repository at this point in the history
…roed pointer
  • Loading branch information
lwahonen committed Feb 23, 2018
1 parent 2856d95 commit 35acd04
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/com/sun/jna/CallbacksTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

import com.sun.jna.Callback.UncaughtExceptionHandler;
import com.sun.jna.CallbacksTest.TestLibrary.CbCallback;
import com.sun.jna.platform.win32.OaIdl;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.PointerByReference;
import com.sun.jna.win32.W32APIOptions;
Expand Down Expand Up @@ -1565,6 +1566,31 @@ public void invoke() { }
}
}

public void testWriteCallback() {
vTable vtable=new vTable();
vtable.callback=new vTable.functionpointer() {
@Override
public int callback(OaIdl.SAFEARRAY runtimeId) {
return 0;
}
};
vtable.write();
}

public static class vTable extends Structure {
public interface functionpointer extends Callback {
int callback(OaIdl.SAFEARRAY runtimeId);
}

public functionpointer callback;

@Override
protected List<String> getFieldOrder() {
return Arrays.asList(new String[]{"callback"});

}
}

public static void main(java.lang.String[] argList) {
junit.textui.TestRunner.run(CallbacksTest.class);
}
Expand Down

0 comments on commit 35acd04

Please sign in to comment.