问题
I have very few knowledges in java so I maybe misunderstood my problem:
I'm working on the Gephi API which is in Java, and I used IKVMC to work on a dll.
I tried to create an empty graph as explained here in the Gephi doc https://github.com/gephi/gephi/wiki/How-to-manipulate-Graph
In C# I tried this:
ProjectController pc;
pc = (ProjectController)org.openide.util.Lookup.getDefault().lookup(typeof(ProjectController));
At the second line I get the following error:
Exception non gérée : System.TypeLoadException: La méthode 'thenComparing' du ty pe 'org.openide.util.lookup.ALPairComparator' de l'assembly 'gephi-toolkit, Vers ion=0.0.0.0, Culture=neutral, PublicKeyToken=null' n'a pas d'implémentation. à org.openide.util.lookup.AbstractLookup.getPairsAsLHS() à org.openide.util.lookup.MetaInfServicesLookup.beforeLookup(Template ) à org.openide.util.lookup.AbstractLookup.lookupItem(Template template) à org.openide.util.lookup.AbstractLookup.lookup(Class clazz) à org.openide.util.Lookup.getDefault() à myproject ....
In english it quickly says that the thenComparing() method has no implemention for the type org.openide.util.lookup.ALPairComparator.
I made some researches and in the decompiled dll, the error seems to be here
internal LinkedHashSet getPairsAsLHS()
{
AbstractLookup.Storage storage = this.enterStorage();
LinkedHashSet result;
try
{
Enumeration enumeration = storage.lookup(ClassLiteral<Object>.Value);
TreeSet.__<clinit>();
TreeSet treeSet = new TreeSet(ALPairComparator.DEFAULT);
I found that thenComparing is a "default" method and in java 8, the default methods are already implemented if I don't say a mistake.
My project has reference to IKVM's java.util library.
So maybe it's a problem that the implementation of default methods is badly supported in C# with ikvm or that thenComparing badly support the type internal ALPairComparator.
Sincerely I have not much idea of where it could come from, so any clue would be welcomed. If you have any questions or need more precisions, ask me.
Thank you for your help.
EDIT: I notice that Gephi isnot compatible with java 1.8 but with java 1.7
EDIT2: I'm trying to replace the org.openide.util packages in my dll with a former version on java 1.7 with IlSpy
回答1:
I solved it.
It seems to be Gephi which is not compatible with java 8, so I used IKVM 7 versions serie for java 7 (avaible at nuget).
I had some problems between IKVM 7.2 and 7.4, it wanted to load 7.4 while I had 7.2.
Finally I made my dll with IKVM 7.2 avaible on sourceforge (with my Windows environement path to a java 7 folder) and I used nuget's IKVM 7.4 in my Visual Studio project's references.
Seems to work properly.
来源:https://stackoverflow.com/questions/30864496/gephis-java-default-method-not-implemented-in-c-sharp-with-an-ikvm-from-dll-lib