Following test case
class Test {
private record Data(String value) {
}
Test(Collection<Data> data) {
data.stream().collect(Collectors.groupingBy(Data::value))
.entrySet().stream()
.filter(entry -> entry.getValue().size() > 1)
.forEach(entry -> {
throw new IllegalArgumentException("Duplicate value " + entry.getKey());
});
}
}
fails compilation with java: [expression.unparsable] Expression invalid in dependent type annotation: [error for expression: data.stream().collect(java.util.stream.Collectors.groupingBy(Data::value)); error: Invalid 'Data::value' because class com.github.javaparser.ast.expr.MethodReferenceExpr is not a supported expression]
on line
.filter(entry -> entry.getValue().size() > 1)
It is expected to compile without warnings