我正在为《我的世界》游戏制作模组。
使用Eclipse一切正常,编译成功,我可以使用创建的mod玩游戏。
但是,当我使用gradle编译代码时,出现此错误:
C:\Users\Alexandre\MCForge\ForgeCreeperHeal\debug\build\sources\main\java\fr\eyzox\dependencygraph\DependencyGraph.java:31: error: method buildIndex in class DataKeyProvider<K> cannot be applied to given types;
node.keyProvider.buildIndex(index, node);
^
required: Map<KEY,DependencyGraph<KEY,? extends IData<KEY>>.Node>,DependencyGraph<KEY,? extends IData<KEY>>.Node
found: Map<KEY,DependencyGraph<KEY,DATA>.Node>,DependencyGraph<KEY,DATA>.Node
reason: actual argument Map<KEY,DependencyGraph<KEY,DATA>.Node> cannot be converted to Map<KEY,DependencyGraph<KEY,? extends IData<KEY>>.Node> by method invocation conversion
where KEY,DATA,K are type-variables:
KEY extends Object declared in class DependencyGraph
DATA extends IData<KEY> declared in class DependencyGraph
K extends Object declared in class DataKeyProvider
我不明白为什么它可以在Eclipse上运行,但不能与gradle一起使用。
也许这是纯Java的泛型误解,但我对此表示怀疑,因为在Eclipse中一切正常。
是我这边的错误还是我应该寻找gradle插件错误?
我是gradle的初学者。
也许需要源代码和build.gradle才能理解我的问题。
我在这里创建了一个仓库:https://github.com/RedRelay/FCH_DEBUG
编辑:这似乎是与Eclipse相关的问题。我刚刚学习了Eclipse有自己的编译器,并且似乎允许使用它而不是标准的javac。
最佳答案
Eclipse有自己的编译器,而不是标准的javac编译器。我变了
protected abstract void buildIndex(final Map<K, DependencyGraph<K, ? extends IData<K>>.Node> index, final DependencyGraph<K, ? extends IData<K>>.Node theNode) throws DuplicateKeyException;
至
protected abstract <D extends IData<K>> void buildIndex(final Map<K, DependencyGraph<K, D>.Node> index, final DependencyGraph<K, D>.Node theNode) throws DuplicateKeyException;
现在就可以了。
关于java - 实际参数…无法通过方法调用转换转换为…,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38837167/