ADDITIONAL SYSTEM INFORMATION :
docker image of openjdk:8
A DESCRIPTION OF THE PROBLEM :
In case a filter method which is invoked in an unchecked manner, the collect(Collector col) fails to compile. For instance, given the attached code, the compiler will fail with this error: error: incompatible types: Object cannot be converted to Collection<Target>
.collect( Collectors.toList());
even if the compiler is instructed to ignore the unchecked code warnings using the -Xlint:unchecked flag.
The code compiles fine (with the right warning) in the openjdk 10 branch.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
javac StreamBugCase.java
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
compiles with warnings
ACTUAL -
doesn't compile
---------- BEGIN SOURCE ----------
import java.util.Collection;
import java.util.stream.Collectors;
public class StreamBugCase
{
Class clazz;
Collection<Target> targets;
public Collection<Target> getTargets()
{
Collection<Target> myTargets = targets.stream()
.filter( t -> t.isApplicable( clazz ) )
.collect( Collectors.toList() );
return myTargets;
}
public interface Target
{
boolean isApplicable(Class<? extends MainType> clazz);
}
public interface MainType
{
}
}
---------- END SOURCE ----------
FREQUENCY : always
docker image of openjdk:8
A DESCRIPTION OF THE PROBLEM :
In case a filter method which is invoked in an unchecked manner, the collect(Collector col) fails to compile. For instance, given the attached code, the compiler will fail with this error: error: incompatible types: Object cannot be converted to Collection<Target>
.collect( Collectors.toList());
even if the compiler is instructed to ignore the unchecked code warnings using the -Xlint:unchecked flag.
The code compiles fine (with the right warning) in the openjdk 10 branch.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
javac StreamBugCase.java
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
compiles with warnings
ACTUAL -
doesn't compile
---------- BEGIN SOURCE ----------
import java.util.Collection;
import java.util.stream.Collectors;
public class StreamBugCase
{
Class clazz;
Collection<Target> targets;
public Collection<Target> getTargets()
{
Collection<Target> myTargets = targets.stream()
.filter( t -> t.isApplicable( clazz ) )
.collect( Collectors.toList() );
return myTargets;
}
public interface Target
{
boolean isApplicable(Class<? extends MainType> clazz);
}
public interface MainType
{
}
}
---------- END SOURCE ----------
FREQUENCY : always