-->

MissingMethodException using IKVM

2019-08-26 10:33发布

问题:

I'm trying to use Stanford CoreNLP (which is a Java project) in C#.

I found this Nuget package which contains CoreNLP converted to .NET using IKVM, and it's working fine, however I need to do some modifications on the java project as well.

I downloaded CoreNLP from 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 that I found in google, I'm doing this:

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 

All I get from the following conversions are a few warnings about referenced classed that can't be found:

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.: I also tried converting protobuf.jar, but didn't help with the problem described below.

Problem is: when I replace the Nuget references for my freshly-compiled references (6 dlls), it compiles fine (finds all references), but throws this MissingMethodException: Additional information: Method not found: 'Void edu.stanford.nlp.pipeline.StanfordCoreNLP..ctor(java.util.Properties)'.

Can anyone shed some light?

回答1:

I guess I figured it out. Here is what fixed:

  1. Removed Nuget Package IKVM 8.0.5449.1
  2. Installed Nuget Package IKVM 8.0.5449.0 (which was the version I was using for converting my JAR files)
  3. Clean and rebuild.

If I understand correctly, the ikvmc.exe I used to convert my JAR files must be the same version of the referenced runtime DLLs.