这是我支持的项目的Java 8代码:
import static com.google.common.base.MoreObjects.*;
import static java.util.Collections.emptyList;
List<String> properties;
properties = firstNonNull(properties, emptyList());
它使用Gradle在本地编译良好,但在Teamcity代理上失败
[14:53:45][:admin-server:compileJava] .../PageRequest.java:24: error: incompatible types: inferred type does not conform to upper bound(s)
[14:53:45][:admin-server:compileJava] properties = firstNonNull(properties, emptyList());
[14:53:45][:admin-server:compileJava] ^
[14:53:45][:admin-server:compileJava] inferred: List<? extends Object>
[14:53:45][:admin-server:compileJava] upper bound(s): List<String>,Object
[14:53:45][:admin-server:compileJava] Note: .../StatsResource.java uses unchecked or unsafe operations.
[14:53:45][:admin-server:compileJava] Note: Recompile with -Xlint:unchecked for details.
[14:53:45][:admin-server:compileJava] 1 error
它有什么问题?我可以用
修复它Collections.<String>emptyList()
但这似乎不是一个选择,因为它不是唯一没有放置泛型的地方。谢谢你的帮助。