我試過jnaerator SimpleMeaningfulExample (http://code.google.com/p/jnaerator/wiki/SimpleMeaningfulExample)和 了:的jnaerator的SimpleMeaningfulExample生成Java JNA包裝程序將無法正常工作
$ java -jar jnaerator-0.9.2.jar -library Test Test.h -o . -v
Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad
version number in .class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:675)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:316)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:280)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:374)
...在Mac OS X 10.5.8和Ubuntu 8.04,兩者運行Java 1.5.0_20。
我切換到1.6.0_15在Mac OS X和再次嘗試,並得到:
$ java -jar jnaerator-0.9.2.jar -library Test Test.h -o . -v
Auto-configuring parser...
Nov 20, 2009 5:12:43 PM com.ochafik.lang.jnaerator.JNAeratorConfigUtils getProp
INFO: [environment] JNAERATOR_INCLUDE_PATH=.:/usr/include
Nov 20, 2009 5:12:43 PM com.ochafik.lang.jnaerator.JNAeratorConfigUtils getProp
INFO: [environment] JNAERATOR_FRAMEWORKS_PATH=/System/Library/Frameworks/CoreServices.framework/Versions/Current/Frameworks:/System/Library/Frameworks/ApplicationServices.framework/Versions/Current/Frameworks:/System/Library/Frameworks:/Library/Frameworks:/Local/Library/Frameworks/:/Users/dspitzer/Library/Frameworks
os.arch = x86_64
Nov 20, 2009 5:12:43 PM com.ochafik.lang.jnaerator.JNAerator jnaerate
INFO: Include path :
.
/usr/include
Parsing native headers...
Writing preprocessor output to '_jnaerator.preprocessed.c'
Writing preprocessor macros to '_jnaerator.macros.cpp'
line 0:-1 Failed to match any alternative with token [@-1,0:0='<no text>',<-1>,0:-1]
File: null:0
Input:
Rule: 1501:1: castExpr returns [Expression expr] : ('(' tr= mutableTypeRef ')' inner= castExpr | e= unaryExpr);
Stack: []
line 0:-1 Failed to match any alternative with token [@-1,0:0='<no text>',<-1>,0:-1]
File: null:0
Input:
Rule: 1501:1: castExpr returns [Expression expr] : ('(' tr= mutableTypeRef ')' inner= castExpr | e= unaryExpr);
Stack: []
line 0:-1 Failed to match any alternative with token [@-1,0:0='<no text>',<-1>,0:-1]
File: null:0
Input:
Rule: 1501:1: castExpr returns [Expression expr] : ('(' tr= mutableTypeRef ')' inner= castExpr | e= unaryExpr);
Stack: []
Now parsing 1 text blocks
Normalizing parsed code...
Generating libraries...
JNAeration failed !
java.lang.NullPointerException
at com.ochafik.lang.jnaerator.TypeConversion.convertExpressionToJava(TypeConversion.java:1391)
at com.ochafik.lang.jnaerator.TypeConversion.convertExpressionToJava(TypeConversion.java:1223)
at com.ochafik.lang.jnaerator.DeclarationsConverter.convertVariablesDeclaration(DeclarationsConverter.java:1087)
at com.ochafik.lang.jnaerator.DeclarationsConverter.convertVariablesDeclaration(DeclarationsConverter.java:1134)
at com.ochafik.lang.jnaerator.DeclarationsConverter.convertStruct(DeclarationsConverter.java:873)
at com.ochafik.lang.jnaerator.DeclarationsConverter.outputConvertedStruct(DeclarationsConverter.java:950)
at com.ochafik.lang.jnaerator.DeclarationsConverter.convertStructs(DeclarationsConverter.java:1055)
at com.ochafik.lang.jnaerator.JNAerator.generateLibraryFiles(JNAerator.java:1102)
at com.ochafik.lang.jnaerator.JNAerator.jnaerationCore(JNAerator.java:1322)
at com.ochafik.lang.jnaerator.JNAerator.jnaerate(JNAerator.java:700)
at com.ochafik.lang.jnaerator.JNAerator$1.finished(JNAerator.java:613)
at com.ochafik.lang.jnaerator.JNAeratorCommandLineArgs$ArgsParser.parse(JNAeratorCommandLineArgs.java:127)
at com.ochafik.lang.jnaerator.JNAerator.main(JNAerator.java:256)
我做錯什麼了嗎?
更新:我張貼了我的問題[email protected](見這個線程:https://jna.dev.java.net/servlets/BrowseList?list=users&by=thread&from=2312620)和奧利維爾Chafik,該JNAerator項目業主收到的答覆。總結:
- 我發現了一個迴歸在JNAerator
- 他上傳了一個固定的快照生成:http://jnaerator.sourceforge.net/maven/com/jnaerator/jnaerator/0.9.3-SNAPSHOT/
- 該生成更好地工作,但並沒有產生TestLibrary.java
- 我提交了一份bug報告:http://code.google.com/p/jnaerator/issues/detail?id=50
更新#2:奧利維爾responded again實現缺乏TestLibrary.java後不一個錯誤,因爲它默認嵌入在生成的Test.jar文件中。
我自己想出了一半*這個問題。在切換到Java 1.6.0_15後,JNAeration失敗(帶有NullPointerException)。我希望有人知道爲什麼。 – 2009-11-21 02:34:21
糟糕。錯過了。剛剛跳過真正閱讀整個第二個輸出粘貼。因爲它看起來像正常運行 – jitter 2009-11-21 09:02:48