nativelibs4java / JNAerator

JNAerator: native bindings generator for JNA / BridJ / Node.js
http://jnaerator.googlecode.com
504 stars 108 forks source link

protected List<T > getFieldOrder() generated code cause compilation issues in Java 1.8 #120

Open bakkiaraj opened 4 years ago

bakkiaraj commented 4 years ago

I am using JNAerator for libclang JNA interface creation. Here is the command used, java -Xmx1300m -jar jnaerator-0.12-shaded.jar -arch win32 libx86/libclang.dll -library libclang -libFile libx86/libclang.dll -I./inc/ ./inc/clang-c/Index.h ./inc/clang-c/Platform.h ./inc/clang-c/CXErrorCode.h ./inc/clang-c/CXString.h ./inc/clang-c/CXCompilationDatabase.h ./inc/clang-c/Documentation.h ./inc/clang-c/BuildSystem.h -mode Directory -f -runtime JNA -o ./generated -rootPackage com.np -skipDeprecated -preferJavac -v The generated code has multiple compilation issues , All of them were are "List" changes to "List", I had done the changes manually.

Ex: public class CXComment extends Structure { / C type : const void / public Pointer ASTNode; / C type : CXTranslationUnit */ public CXTranslationUnit TranslationUnit; public CXComment() { super(); } protected List getFieldOrder() { return Arrays.asList("ASTNode", "TranslationUnit"); } /**

Please update the code in a way that List is used in the generated code.

jmnpedrosa commented 4 years ago

I'm having the same issue.

To clarify, any generated classes that extend Structure are overriding the method getFieldOrder incorrectly (with a return type of List<T >), causing compilation errors.

For example:

protected List<T > getFieldOrder() {
  return Arrays.asList("fSpatialType", "fSpatialValidityUnion");
}

It should be:

protected List<String> getFieldOrder() {
  return Arrays.asList("fSpatialType", "fSpatialValidityUnion");
}

I tested this in Java 8 with JNA 4.5.8 and the maven-jnaerator-plugin version 0.12.