在Java源代码上运行Ant构建时遇到以下错误:
[javac] /home/path/to/my/java/function/VarStatusLog.java:28: error: no suitable method found for sort(List<VarStatusMsg<? extends Number>>)
[javac] Collections.sort(logMsg);
[javac] ^
[javac] method Collections.<T#1>sort(List<T#1>) is not applicable
[javac] (inference variable T#1 has incompatible bounds
[javac] equality constraints: VarStatusMsg<? extends Number>
[javac] upper bounds: VarStatusMsg<CAP#1>,Comparable<? super T#1>)
[javac] method Collections.<T#2>sort(List<T#2>,Comparator<? super T#2>) is not applicable
[javac] (cannot infer type-variable(s) T#2
[javac] (actual and formal argument lists differ in length))
[javac] where T#1,T#2 are type-variables:
[javac] T#1 extends Comparable<? super T#1> declared in method <T#1>sort(List<T#1>)
[javac] T#2 extends Object declared in method <T#2>sort(List<T#2>,Comparator<? super T#2>)
[javac] where CAP#1 is a fresh type-variable:
[javac] CAP#1 extends Number from capture of ? extends Number
我在我的Ant版本中使用JDK 1.8。请注意,Windows上的Eclipse不会抛出错误,但是当我从Linux上的命令行运行时,我收到错误。有谁可以帮我这个?提前谢谢!
答案 0 :(得分:2)
我说SELECT
F4111_1.orderID,
F4111_1.orderTYPE,
F4111_1.orderLINE,
F4111_1.orderITEM,
F4111_1.orderQUANTITY
FROM F4111 F4111_1
WHERE
F4111_1.orderTYPE='OU' AND
F4111_1.orderID in (SELECT DISTINCT (F4111.orderID+1) FROM F4111 F4111
WHERE F4111.orderDATE='2016/05/09' AND F4111.orderTYPE='SU' AND F4111.orderDESTINY='333333')
没有实现接口VarStatusMsg
。您使用的Comparable<VarStatusMsg>
方法的签名是sort
。让public static <T extends Comparable<? super T>> void sort(List<T> list)
实现界面VarStatusMsg
,或者将Comparable<VarStatusMsg>
作为Comparator<VarStatusMsg>
的第二个参数。
顺便说一下。您只需拨打sort
而不是logMsg.sort(null)
或Collections.sort(logMsg)
而不是logMsg.sort(myNiceComparator)
。 Collections.sort(logMsg, myNiceComparator)
方法现在仅委托给Collections
。