使用 IKVMC 将 Java 转换为 .NET 库 - 警告 IKVMC0108:不是类文件
有一个Java工具(称为Mallet) http://mallet.cs.umass.edu/download.php 我想在我的 .NET 项目中使用它。
为了首先将此工具转换为 .NET 库,我尝试使用 Apache Ant 在单个 .jar 文件中构建它。我已完成与上面链接中的说明相对应的所有操作。
从 Mercurial 存储库下载开发人员版本。
下载 Apache Ant,安装 JDK,设置 JAVA_HOME var 以使用 Apache Ant。
使用 Ant,我构建了单个 mallet.jar 文件。
然后我会使用 IKVMC 将 mallet.jar 转换为 .NET 库。 转换时,我收到很多警告,例如:
Warning IKVMC0108: not a class file "cc/mallet/util/tests/TestPriorityQueue$1.cl
ass", including it as resource
(class format error "51.0")
尽管有这些警告,还是创建了 mallet.dll。但是当我尝试从我的 .NET 项目中引用它时,它看起来“空”。它没有任何类或名称空间。我不会忘记引用 IKVM.OpenJDL.Core。
这很不寻常,我在谷歌中找不到任何相同的问题。
我认为问题在于警告。而且我从未使用过Ant,所以我不太了解所有流程。
There is Java tool (it is called Mallet)
http://mallet.cs.umass.edu/download.php
which I want to use in my .NET project.
To convert this tool to .NET library at first I've tried to build it in single .jar file using Apache Ant. I've done everything corresponding to instructions at link above.
Download Developer Release from Mercurial repository.
Download Apache Ant, install JDK, set JAVA_HOME var to use Apache Ant.
Using Ant I've built single mallet.jar file.
And then I would to convert mallet.jar to .NET library using IKVMC.
When converting, I've got a lot of warnings such as:
Warning IKVMC0108: not a class file "cc/mallet/util/tests/TestPriorityQueue$1.cl
ass", including it as resource
(class format error "51.0")
Despite of these warnings, mallet.dll was created. But when I try to reference to it from my .NET project, it looks "empty". It has not any classes or namespaces. I don't forget to reference to IKVM.OpenJDL.Core.
And this is unusual that I can't find any same problems in Google.
I think that problem is in warnings. And I have never worked with Ant and I don't understand all process exactly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
类格式版本 51 是随 Java 7 引入的。IKVM
很可能还不支持该版本,并且您引用的文件名 (
cc/mallet/util/tests/TestPriorityQueue$1.class
) 指向TestPriorityQueue
的匿名内部类肯定是库正常工作所必需的。我的建议:使用较旧的 JDK 编译 Mallet,或者至少使用将
-source
和-target
开关设置为6
(以确保它针对 Java 6 进行编译)。The class format version 51 was introduced with Java 7.
IKVM most likely doesn't support that version yet and the file name you quote (
cc/mallet/util/tests/TestPriorityQueue$1.class
) points at an anonymous inner class ofTestPriorityQueue
that certainly is needed for the library to work correctly.My suggestion: compile Mallet using an older JDK or at least using the
-source
and-target
switches set to6
(to ensure that it's compile for Java 6).仅供参考 IKVM v8.1(当前处于 RC 版本)支持 Java 8:
http:// weblog.ikvm.net/2015/08/26/IKVMNET81ReleaseCandidate0.aspx
http://sourceforge.net/p/ikvm/mailman/message/34502991/
FYI v8.1 (currently in RC) of IKVM supports Java 8:
http://weblog.ikvm.net/2015/08/26/IKVMNET81ReleaseCandidate0.aspx
http://sourceforge.net/p/ikvm/mailman/message/34502991/