3

Is there a way to map method names, member variables, struct data etc. when the member name is a java reserved keyword? I am creating a JNA wrapper for a third party C-library, whose sources I am not able to modify. A simplified example would be this:

// C-library
typedef struct {
    const char* name;
} Class;

typedef struct {
    const Class *class
} Context;

So to map this to JNA I have a class

public static class Context extends Structure {
    public Pointer class; // <-- compile error, reserved keyword
}

Is there any way around this? I tried looking at JNA sources (I'm using version 3.2.2) but didn't find anything related.

1 Answers1

3

Structure field names are arbitrary, as long as they are unique, properly typed, and in the correct order, the information will be the same. I would recommend at least making them similar to the original, though (class_ or klass will work).

You can remap function names with a FunctionMapper.

technomage
  • 9,861
  • 2
  • 26
  • 40