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

jna unsupported datatypes but jnaerator converts them anyways #289

johnny-tc opened this Issue Mar 14, 2012 · 1 comment


None yet
2 participants

johnny-tc commented Mar 14, 2012

On windows, there are data types that seem to get mapped strangely (well legacy crap). Perhaps JNAerator should reject
trying to convert them with some error message (or use some sort of intrinsic knowledge if ran on a windows platform to convert them over to an int or byte respectively). The APIs that have these somewhat weird data types seem not to
work properly unless the types match up.


typedef BOOL int; //

void foo(BOOL); // maybe map to void foo(int int1);
void foo2(bool); // maybe map to void foo (byte byte1);

gets converted to this:

package test;
import com.ochafik.lang.jnaerator.runtime.LibraryExtractor;
import com.ochafik.lang.jnaerator.runtime.MangledFunctionMapper;
import com.ochafik.lang.jnaerator.runtime.Mangling;
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.NativeLibrary;

  • JNA Wrapper for library test
  • This file was autogenerated by JNAerator,
  • a tool written by Olivier Chafik that uses a few opensource projects..
  • For help, please visit NativeLibs4Java , Rococoa, or JNA.
    public interface TestLibrary extends Library {
    public static final String JNA_LIBRARY_NAME = LibraryExtractor.getLibraryPath("test", true, TestLibrary.class);
    public static final NativeLibrary JNA_NATIVE_LIB = NativeLibrary.getInstance(TestLibrary.JNA_LIBRARY_NAME, MangledFunctionMapper.DEFAULT_OPTIONS);
    public static final TestLibrary INSTANCE = (TestLibrary)Native.loadLibrary(TestLibrary.JNA_LIBRARY_NAME, TestLibrary.class, MangledFunctionMapper.DEFAULT_OPTIONS);
    • Original signature : void foo(BOOL)
    • native declaration : line 4
      @mangling({"Z3foo4BOOL", "?foo@@YAX4BOOL@Z"})
      void foo(boolean BOOL1);
    • Original signature : void foo2(bool)
    • native declaration : line 5
      @mangling({"_Z4foo2b", "?foo2@@YAX_N@Z"})
      void foo2(boolean bool1);

This comment has been minimized.


ochafik commented Mar 20, 2012

Hi @johnny-tc ,

Thanks for your report.

I've fixed the mapping of C++ bool type to byte for JNA target runtime, although this will obviously only work for functions in extern "C" blocks (or with the exact Mangling annotation).


@ochafik ochafik closed this Mar 20, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment