FULL PRODUCT VERSION :
java version "1.6.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-beta2-b73)
Java HotSpot(TM) Client VM (build 1.6.0-beta2-b73, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
When I test my code with 1.6.0-beta2-b73, a new compiler error was introduced to my code.
####
import java.util.Iterator;
import java.util.List;
public class GenericsTest<A> {
interface Factory<T> {
T invoke();
}
public static <E> Iterator<E> iterate(Iterable<E> iterable) {
return iterable.iterator();
}
public Factory<Iterator<? extends A>> factory(final Factory<? extends List<? extends A>> factory) {
return new Factory<Iterator<? extends A>>() {
public Iterator<? extends A> invoke() {
return iterate(factory.invoke());
}
};
}
}
####
Removing one of the '? extends ...' parts in the declaration of the parameter factory
public Factory<Iterator<? extends A>> factory(final Factory<List<? extends A>> factory)
or
public Factory<Iterator<? extends A>> factory(final Factory<? extends
List<A>> factory)
or calling the iterator method directly on the generated object
return factory.invoke().iterator();
causes 1.6.0-beta2-b73 to remove the error.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Simply try to compile the specified code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The code should be compiled without errors.
ACTUAL -
The code produces the specified error.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Test.java:17: <E>iterate(java.lang.Iterable<E>) in Test<A> cannot be applied to
(capture#276 of ? extends java.util.List<? extends A>)
return iterate(factory.invoke());
^
1 error
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.Iterator;
import java.util.List;
public class GenericsTest<A> {
interface Factory<T> {
T invoke();
}
public static <E> Iterator<E> iterate(Iterable<E> iterable) {
return iterable.iterator();
}
public Factory<Iterator<? extends A>> factory(final Factory<? extends List<? extends A>> factory) {
return new Factory<Iterator<? extends A>>() {
public Iterator<? extends A> invoke() {
return iterate(factory.invoke());
}
};
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Removing one of the '? extends ...' parts in the declaration of the parameter factory
public Factory<Iterator<? extends A>> factory(final Factory<List<? extends A>> factory)
or
public Factory<Iterator<? extends A>> factory(final Factory<? extends
List<A>> factory)
or calling the iterator method directly on the generated object
return factory.invoke().iterator();
causes 1.6.0-beta2-b73 to remove the error.
Release Regression From : 5.0
The above release value was the last known release where this
bug was known to work. Since then there has been a regression.
java version "1.6.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-beta2-b73)
Java HotSpot(TM) Client VM (build 1.6.0-beta2-b73, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
When I test my code with 1.6.0-beta2-b73, a new compiler error was introduced to my code.
####
import java.util.Iterator;
import java.util.List;
public class GenericsTest<A> {
interface Factory<T> {
T invoke();
}
public static <E> Iterator<E> iterate(Iterable<E> iterable) {
return iterable.iterator();
}
public Factory<Iterator<? extends A>> factory(final Factory<? extends List<? extends A>> factory) {
return new Factory<Iterator<? extends A>>() {
public Iterator<? extends A> invoke() {
return iterate(factory.invoke());
}
};
}
}
####
Removing one of the '? extends ...' parts in the declaration of the parameter factory
public Factory<Iterator<? extends A>> factory(final Factory<List<? extends A>> factory)
or
public Factory<Iterator<? extends A>> factory(final Factory<? extends
List<A>> factory)
or calling the iterator method directly on the generated object
return factory.invoke().iterator();
causes 1.6.0-beta2-b73 to remove the error.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Simply try to compile the specified code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The code should be compiled without errors.
ACTUAL -
The code produces the specified error.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Test.java:17: <E>iterate(java.lang.Iterable<E>) in Test<A> cannot be applied to
(capture#276 of ? extends java.util.List<? extends A>)
return iterate(factory.invoke());
^
1 error
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.Iterator;
import java.util.List;
public class GenericsTest<A> {
interface Factory<T> {
T invoke();
}
public static <E> Iterator<E> iterate(Iterable<E> iterable) {
return iterable.iterator();
}
public Factory<Iterator<? extends A>> factory(final Factory<? extends List<? extends A>> factory) {
return new Factory<Iterator<? extends A>>() {
public Iterator<? extends A> invoke() {
return iterate(factory.invoke());
}
};
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Removing one of the '? extends ...' parts in the declaration of the parameter factory
public Factory<Iterator<? extends A>> factory(final Factory<List<? extends A>> factory)
or
public Factory<Iterator<? extends A>> factory(final Factory<? extends
List<A>> factory)
or calling the iterator method directly on the generated object
return factory.invoke().iterator();
causes 1.6.0-beta2-b73 to remove the error.
Release Regression From : 5.0
The above release value was the last known release where this
bug was known to work. Since then there has been a regression.
- relates to
-
JDK-6227936 Wrong type of inherited method using specialized type parameter
-
- Closed
-
-
JDK-6359951 Class field usage in generic
-
- Closed
-
-
JDK-6893625 Generics case does not compile
-
- Open
-
-
JDK-7034922 4.9: Clarify membership of intersection types for wildcard parameterizations
-
- Open
-
-
JDK-8081318 Diamond inference fails to infer capture variable parameterization
-
- Open
-