Java ternary operator influence on generics type inference
Compiles for me fine in java 8. Earlier versions of Java might need more help return retval == null ? Collections.<String>emptyList() : retval; should work. EDIT This is due to improvements in Java 8 type inference as explained here http://openjdk.java.net/jeps/101 And here’s a blog with the highlights: http://blog.jooq.org/2013/11/25/a-lesser-known-java-8-feature-generalized-target-type-inference/