Cassandra编译关于lambda的问题

时间:2015-09-06 07:54:09

标签: java lambda cassandra java-8

Cassandra源代码是最新的,可以从git@github.com克隆:apache / cassandra.git。

JDK版本为1.8.0_05

OS:Linux 3.13.0-62-generic#102-Ubuntu SMP

[javac] **/cassandra/test/burn/org/apache/cassandra/utils/LongBTreeTest.java:83: error: reference to testRandomSelection is ambiguous
[javac]         testRandomSelection(perThreadTrees, perTreeSelections,
[javac]         ^
[javac]   both method testRandomSelection(int,int,BTreeTestFactory) in LongBTreeTest and method testRandomSelection(int,int,Consumer<RandomSelection>) in LongBTreeTest match
[javac] **/cassandra/test/burn/org/apache/cassandra/utils/LongBTreeTest.java:157: error: reference to testRandomSelection is ambiguous
[javac]         testRandomSelection(perThreadTrees, 4,
[javac]         ^
[javac]   both method testRandomSelection(int,int,BTreeTestFactory) in LongBTreeTest and method testRandomSelection(int,int,Consumer<RandomSelection>) in LongBTreeTest match
[javac] **/cassandra/test/burn/org/apache/cassandra/utils/LongBTreeTest.java:158: error: incompatible types: bad return type in lambda expression
[javac]                             (selection) ->
[javac]                             ^
[javac]     missing return value
[javac] **/cassandra/test/burn/org/apache/cassandra/utils/LongBTreeTest.java:269: error: reference to testRandomSelection is ambiguous
[javac]         testRandomSelection(perThreadTrees, perTreeSelections, (selection) -> {
[javac]         ^
[javac]   both method testRandomSelection(int,int,BTreeTestFactory) in LongBTreeTest and method testRandomSelection(int,int,Consumer<RandomSelection>) in LongBTreeTest match
[javac] **/cassandra/test/burn/org/apache/cassandra/utils/LongBTreeTest.java:269: error: incompatible types: bad return type in lambda expression
[javac]         testRandomSelection(perThreadTrees, perTreeSelections, (selection) -> {
[javac]                                                                ^
[javac]     missing return value

后来,我尝试使用不同的JDK版本编译它,发现jdk1.8.0_11仍然有同样的问题,但从jdk1.8.0_20开始,这个问题是固定的。

我想问一下导致这个问题的原因。任何人都可以告诉我JDK的bug id吗?

1 个答案:

答案 0 :(得分:3)

看起来JDK-8029718错误在1.8.0_20中实际修复了。通常,在与lambda类型推断相关的javac编译器中,1.8.0_20和1.8.0_40中修复了许多错误。建议使用最新的编译器版本。