Guillaume,
Good question! You can only use method references when Java can infer the type. The problem here is that the Comparator isn't specific enough.
You can tell that Java is relying on the comparator to determine the return type because neither of these compile:
Going back to your example, if you tell Java that the comparator is dealing with Strings, it has enough information to use to determine what the method references should be:
It is weird that it works without a method reference. The difference there is you have an actual
String in the lambda version so Java knows which type/method you want. Whereas the method reference X::Y could expand to a static method X.y(a) or an instance method on type X a.y(). In your example, it doesn't know whether to use String.length(s) or s.length(). We know because one doesn't exist, but Java isn't that smart when compiling.