A couple of Bugs
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Tue Jun 7 01:44:55 PDT 2011
Hi Ali,
the static error you are seeing is a result of the fix for 5081782 (type
arguments to non-generic methods) - if you remove the explicit
type-argument from the following invocation:
public static <A> Array<A> test() {
return Array.<A>array();
}
You get the very same error in JDK 6. Thus, the new error in JDK 7 is
caused by the fact that the method Array.array() is not excluded anymore
from overload resolution because of explicit type-arguments.
The other is a problem with overload resolution and nested lambda
expression, and will be fixed.
Maurizio
On 07/06/11 04:53, Ali Ebrahimi wrote:
> class Test {
>
> static class Array<A> {
> private A[] data;
>
> Array(A[] data) {
> this.data = data;
> }
>
> public static<A> Array<A> array(final A... a) {
> return new Array<A>(a);
> }
>
> public A[] array() {
> return null;
> }
>
> public boolean forAll(final F<A, Boolean> f) {
> for (final A x : data)
> if (f.f(x))
> return true;
>
> return false;
> }
>
> }
>
> public interface F<A, B> {
> B f(A a);
> }
>
> public static<A> Array<A> test() {
> return Array.<A>array();
> }
>
> public static Array<Character> fromString(final String s) {
> List<Character> cs = Collections.emptyList();
>
> for (int i = s.length() - 1; i>= 0; i--)
> cs.add(s.charAt(i));
>
> return new Array<Character>(cs.toArray(new Character[0]));
> }
>
> public static void main(String[] args) {
>
> final Array<String> a = Array.array("Hello", "There", "what", "DAY",
> "iS", "iT");
> final boolean b = a.forAll(#{String s -> fromString(s).forAll(#{
> Character c -> isLowerCase(c)}) }); //***********
> System.out.println(b); // true ("what" provides the only example;
> try removing it)
> }
> }
More information about the lambda-dev
mailing list