使用 IKVM 的 MissingMethodException
MissingMethodException using IKVM
我正在尝试在 C# 中使用 Stanford CoreNLP(这是一个 Java 项目)。
我发现这个 Nuget package 包含使用 IKVM 转换为 .NET 的 CoreNLP,它工作正常,但是我还需要对 java 项目做一些修改。
我从 google 中找到的 Github, I can build the CoreNLP JAR from Ant, and it's also running fine in eclipse, however I'm having problems in converting JAR to DLL. Based on some build-log 下载了 CoreNLP,我正在这样做:
ikvmc.exe -version:2.1 ..\lib\joda-time.jar -out:joda-time.dll
ikvmc.exe -r:joda-time.dll -version:0.4.7 ..\lib\jollyday-0.4.7.jar -out:jollyday.dll
ikvmc.exe -version:0.23 ..\lib\ejml-0.23.jar -out:ejml-0.23.dll
ikvmc.exe -version:1.2.10 ..\lib\xom-1.2.10.jar -out:xom.dll
ikvmc.exe -version:1.0 ..\lib\javax.json.jar -out:javax.json.dll
ikvmc.exe -r:joda-time.dll -r:jollyday.dll -r:ejml-0.23.dll -r:xom.dll -r:javax.json.dll -version:3.5.0 ..\javanlp-core.jar -out:javanlp-core.dll
我从以下转换中得到的只是一些关于无法找到的引用分类的警告:
warning IKVMC0100: Class "org.apache.xerces.parsers.SAXParser" not found
warning IKVMC0100: Class "junit.framework.TestCase" not found
warning IKVMC0100: Class "org.apache.xerces.impl.Version" not found
...
warning IKVMC0100: Class "junit.framework.TestCase" not found
warning IKVMC0100: Class "javax.servlet.http.HttpServlet" not found
warning IKVMC0100: Class "javax.servlet.Filter" not found
warning IKVMC0100: Class "com.google.protobuf.Descriptors$FileDescriptor$InternalDescriptorAssigner" not found
warning IKVMC0100: Class "com.google.protobuf.GeneratedMessage$Builder" not found
warning IKVMC0100: Class "com.google.protobuf.GeneratedMessage" not found
warning IKVMC0100: Class "com.google.protobuf.MessageOrBuilder" not found
warning IKVMC0100: Class "com.google.protobuf.GeneratedMessage$ExtendableBuilder" not found
warning IKVMC0100: Class "com.google.protobuf.GeneratedMessage$ExtendableMessage" not found
warning IKVMC0100: Class "com.google.protobuf.GeneratedMessage$ExtendableMessageOrBuilder" not found
warning IKVMC0100: Class "com.google.protobuf.Internal$EnumLiteMap" not found
warning IKVMC0100: Class "com.google.protobuf.ProtocolMessageEnum" not found
warning IKVMC0100: Class "junit.framework.TestSuite" not found
warning IKVMC0100: Class "junit.framework.Assert" not found
warning IKVMC0100: Class "com.apple.eawt.ApplicationAdapter" not found
warning IKVMC0100: Class "org.junit.Assert" not found
warning IKVMC0100: Class "org.apache.lucene.analysis.core.KeywordAnalyzer" not found
warning IKVMC0100: Class "org.apache.lucene.index.IndexWriterConfig" not found
warning IKVMC0100: Class "org.apache.lucene.util.Version" not found
warning IKVMC0100: Class "org.apache.lucene.store.FSDirectory" not found
warning IKVMC0100: Class "org.apache.lucene.index.DirectoryReader" not found
warning IKVMC0100: Class "org.apache.lucene.search.IndexSearcher" not found
warning IKVMC0100: Class "org.apache.lucene.search.BooleanQuery" not found
warning IKVMC0100: Class "org.apache.lucene.search.BooleanClause" not found
warning IKVMC0100: Class "org.apache.lucene.search.TermQuery" not found
warning IKVMC0100: Class "org.apache.lucene.index.Term" not found
warning IKVMC0100: Class "org.apache.lucene.search.BooleanClause$Occur" not found
warning IKVMC0100: Class "org.apache.lucene.search.TopDocs" not found
warning IKVMC0100: Class "org.apache.lucene.search.ScoreDoc" not found
warning IKVMC0100: Class "org.apache.lucene.document.Document" not found
warning IKVMC0100: Class "org.apache.lucene.index.IndexWriter" not found
warning IKVMC0100: Class "org.apache.lucene.queryparser.classic.ParseException" not found
warning IKVMC0100: Class "org.apache.lucene.document.StringField" not found
warning IKVMC0100: Class "org.apache.lucene.document.Field$Store" not found
warning IKVMC0100: Class "org.apache.lucene.document.Field" not found
warning IKVMC0100: Class "org.apache.lucene.search.Query" not found
warning IKVMC0100: Class "org.apache.lucene.store.Directory" not found
warning IKVMC0100: Class "org.apache.lucene.index.CheckIndex" not found
warning IKVMC0100: Class "org.apache.lucene.index.CheckIndex$Status" not found
warning IKVMC0100: Class "org.apache.lucene.store.NIOFSDirectory" not found
warning IKVMC0100: Class "org.apache.lucene.util.BytesRef" not found
warning IKVMC0100: Class "org.apache.lucene.index.IndexReader" not found
warning IKVMC0100: Class "com.google.protobuf.Descriptors$FileDescriptor" not found
warning IKVMC0100: Class "com.google.protobuf.Descriptors$Descriptor" not found
warning IKVMC0100: Class "com.google.protobuf.GeneratedMessage$FieldAccessorTable" not found
warning IKVMC0100: Class "com.google.protobuf.Descriptors" not found
warning IKVMC0100: Class "junit.framework.AssertionFailedError" not found
warning IKVMC0100: Class "org.apache.lucene.document.FieldType" not found
P.S.: 我也试过转换 protobuf.jar,但没有帮助解决下面描述的问题。
问题是:当我为新编译的引用(6 个 dll)替换 Nuget 引用时,它编译正常(找到所有引用),但抛出此 MissingMethodException:附加信息:找不到方法: 'Void edu.stanford.nlp.pipeline.StanfordCoreNLP..ctor(java.util.Properties)'.
任何人都可以阐明一下吗?
我想我明白了。这是修复的内容:
- 删除了 Nuget 包 IKVM 8.0.5449.1
- 已安装 Nuget 包 IKVM 8.0.5449.0(这是我用来转换 JAR 文件的 version)
- 清理并重建。
如果我理解正确,我用来转换 JAR 文件的 ikvmc.exe 必须与引用的运行时 DLL 的版本相同。
我正在尝试在 C# 中使用 Stanford CoreNLP(这是一个 Java 项目)。
我发现这个 Nuget package 包含使用 IKVM 转换为 .NET 的 CoreNLP,它工作正常,但是我还需要对 java 项目做一些修改。
我从 google 中找到的 Github, I can build the CoreNLP JAR from Ant, and it's also running fine in eclipse, however I'm having problems in converting JAR to DLL. Based on some build-log 下载了 CoreNLP,我正在这样做:
ikvmc.exe -version:2.1 ..\lib\joda-time.jar -out:joda-time.dll
ikvmc.exe -r:joda-time.dll -version:0.4.7 ..\lib\jollyday-0.4.7.jar -out:jollyday.dll
ikvmc.exe -version:0.23 ..\lib\ejml-0.23.jar -out:ejml-0.23.dll
ikvmc.exe -version:1.2.10 ..\lib\xom-1.2.10.jar -out:xom.dll
ikvmc.exe -version:1.0 ..\lib\javax.json.jar -out:javax.json.dll
ikvmc.exe -r:joda-time.dll -r:jollyday.dll -r:ejml-0.23.dll -r:xom.dll -r:javax.json.dll -version:3.5.0 ..\javanlp-core.jar -out:javanlp-core.dll
我从以下转换中得到的只是一些关于无法找到的引用分类的警告:
warning IKVMC0100: Class "org.apache.xerces.parsers.SAXParser" not found
warning IKVMC0100: Class "junit.framework.TestCase" not found
warning IKVMC0100: Class "org.apache.xerces.impl.Version" not found
...
warning IKVMC0100: Class "junit.framework.TestCase" not found
warning IKVMC0100: Class "javax.servlet.http.HttpServlet" not found
warning IKVMC0100: Class "javax.servlet.Filter" not found
warning IKVMC0100: Class "com.google.protobuf.Descriptors$FileDescriptor$InternalDescriptorAssigner" not found
warning IKVMC0100: Class "com.google.protobuf.GeneratedMessage$Builder" not found
warning IKVMC0100: Class "com.google.protobuf.GeneratedMessage" not found
warning IKVMC0100: Class "com.google.protobuf.MessageOrBuilder" not found
warning IKVMC0100: Class "com.google.protobuf.GeneratedMessage$ExtendableBuilder" not found
warning IKVMC0100: Class "com.google.protobuf.GeneratedMessage$ExtendableMessage" not found
warning IKVMC0100: Class "com.google.protobuf.GeneratedMessage$ExtendableMessageOrBuilder" not found
warning IKVMC0100: Class "com.google.protobuf.Internal$EnumLiteMap" not found
warning IKVMC0100: Class "com.google.protobuf.ProtocolMessageEnum" not found
warning IKVMC0100: Class "junit.framework.TestSuite" not found
warning IKVMC0100: Class "junit.framework.Assert" not found
warning IKVMC0100: Class "com.apple.eawt.ApplicationAdapter" not found
warning IKVMC0100: Class "org.junit.Assert" not found
warning IKVMC0100: Class "org.apache.lucene.analysis.core.KeywordAnalyzer" not found
warning IKVMC0100: Class "org.apache.lucene.index.IndexWriterConfig" not found
warning IKVMC0100: Class "org.apache.lucene.util.Version" not found
warning IKVMC0100: Class "org.apache.lucene.store.FSDirectory" not found
warning IKVMC0100: Class "org.apache.lucene.index.DirectoryReader" not found
warning IKVMC0100: Class "org.apache.lucene.search.IndexSearcher" not found
warning IKVMC0100: Class "org.apache.lucene.search.BooleanQuery" not found
warning IKVMC0100: Class "org.apache.lucene.search.BooleanClause" not found
warning IKVMC0100: Class "org.apache.lucene.search.TermQuery" not found
warning IKVMC0100: Class "org.apache.lucene.index.Term" not found
warning IKVMC0100: Class "org.apache.lucene.search.BooleanClause$Occur" not found
warning IKVMC0100: Class "org.apache.lucene.search.TopDocs" not found
warning IKVMC0100: Class "org.apache.lucene.search.ScoreDoc" not found
warning IKVMC0100: Class "org.apache.lucene.document.Document" not found
warning IKVMC0100: Class "org.apache.lucene.index.IndexWriter" not found
warning IKVMC0100: Class "org.apache.lucene.queryparser.classic.ParseException" not found
warning IKVMC0100: Class "org.apache.lucene.document.StringField" not found
warning IKVMC0100: Class "org.apache.lucene.document.Field$Store" not found
warning IKVMC0100: Class "org.apache.lucene.document.Field" not found
warning IKVMC0100: Class "org.apache.lucene.search.Query" not found
warning IKVMC0100: Class "org.apache.lucene.store.Directory" not found
warning IKVMC0100: Class "org.apache.lucene.index.CheckIndex" not found
warning IKVMC0100: Class "org.apache.lucene.index.CheckIndex$Status" not found
warning IKVMC0100: Class "org.apache.lucene.store.NIOFSDirectory" not found
warning IKVMC0100: Class "org.apache.lucene.util.BytesRef" not found
warning IKVMC0100: Class "org.apache.lucene.index.IndexReader" not found
warning IKVMC0100: Class "com.google.protobuf.Descriptors$FileDescriptor" not found
warning IKVMC0100: Class "com.google.protobuf.Descriptors$Descriptor" not found
warning IKVMC0100: Class "com.google.protobuf.GeneratedMessage$FieldAccessorTable" not found
warning IKVMC0100: Class "com.google.protobuf.Descriptors" not found
warning IKVMC0100: Class "junit.framework.AssertionFailedError" not found
warning IKVMC0100: Class "org.apache.lucene.document.FieldType" not found
P.S.: 我也试过转换 protobuf.jar,但没有帮助解决下面描述的问题。
问题是:当我为新编译的引用(6 个 dll)替换 Nuget 引用时,它编译正常(找到所有引用),但抛出此 MissingMethodException:附加信息:找不到方法: 'Void edu.stanford.nlp.pipeline.StanfordCoreNLP..ctor(java.util.Properties)'.
任何人都可以阐明一下吗?
我想我明白了。这是修复的内容:
- 删除了 Nuget 包 IKVM 8.0.5449.1
- 已安装 Nuget 包 IKVM 8.0.5449.0(这是我用来转换 JAR 文件的 version)
- 清理并重建。
如果我理解正确,我用来转换 JAR 文件的 ikvmc.exe 必须与引用的运行时 DLL 的版本相同。