Diamond operator no longer working... ?
assembling signals
assembling.signals at yandex.ru
Fri Mar 18 17:01:17 UTC 2011
Hello, community!
I noticed a new error since b134: "Cannot use '<>' with anonymous inner classes".
The code uses diamond syntax and was error-free before b134.
(Please see reproducible example at the end.)
Can someone explain: is this error even intended?
If so, why this is necessary? If not, is it possible to revert to old behavior?
(BTW: Latest Netbeans even allow to refactor anon-inner-classes to use diamond syntax.)
Best regards,
Ivan G Shevchenko
= = = = = = = = = =
EXAMPLE CODE:
= = = = = = = = = =
import java.util.*;
public final class DiamondTestJdkBuild134 {
public static void main(String... args) {
// no error
List<String> l = new LinkedList<>();
// error: cannot infer type arguments for Iterator;
// reason: cannot use '<>' with anonymous inner classes
Iterator<String> i = new Iterator<>() {
@Override
public boolean hasNext() {
return false;
}
@Override
public String next() {
return null;
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
};
}
}
More information about the core-libs-dev
mailing list