-
Bug
-
Resolution: Unresolved
-
P4
-
8u60, 9
FULL PRODUCT VERSION :
javac -version
javac 1.8.0_60
ADDITIONAL OS VERSION INFORMATION :
Linux desktop 4.1.6-1-ARCH #1 SMP PREEMPT Mon Aug 17 08:52:28 CEST 2015 x86_64 GNU/Linux
Linux lab 3.13.0-63-generic #103-Ubuntu SMP Fri Aug 14 21:43:30 UTC 2015 i686 i686 i686 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
The attached code does not compile. It should. It did at least in 1.8.0_25
REGRESSION. Last worked in version 8u40
ADDITIONAL REGRESSION INFORMATION:
This code compiled and worked fine in 1.8.0_25
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Error:(15, 20) java: method unmodifiableList in class java.util.Collections cannot be applied to given types;
required: java.util.List<? extends T>
found: java.util.Collection<Main>
reason: cannot infer type-variable(s) E
(actual and formal argument lists differ in length)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.stream.Collectors;
class Main {
static Collection<Main> list = null;
public static void main(String[] args) {
Collections.unmodifiableList(list.stream().collect(Collectors.toCollection(ArrayList::new)));
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.stream.Collectors;
class Main {
static Collection<Main> list = null;
static ArrayList create() {
return new ArrayList();
}
public static void main(String[] args) {
Collections.unmodifiableList(list.stream().collect(Collectors.toCollection(Main::create)));
}
}
javac -version
javac 1.8.0_60
ADDITIONAL OS VERSION INFORMATION :
Linux desktop 4.1.6-1-ARCH #1 SMP PREEMPT Mon Aug 17 08:52:28 CEST 2015 x86_64 GNU/Linux
Linux lab 3.13.0-63-generic #103-Ubuntu SMP Fri Aug 14 21:43:30 UTC 2015 i686 i686 i686 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
The attached code does not compile. It should. It did at least in 1.8.0_25
REGRESSION. Last worked in version 8u40
ADDITIONAL REGRESSION INFORMATION:
This code compiled and worked fine in 1.8.0_25
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Error:(15, 20) java: method unmodifiableList in class java.util.Collections cannot be applied to given types;
required: java.util.List<? extends T>
found: java.util.Collection<Main>
reason: cannot infer type-variable(s) E
(actual and formal argument lists differ in length)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.stream.Collectors;
class Main {
static Collection<Main> list = null;
public static void main(String[] args) {
Collections.unmodifiableList(list.stream().collect(Collectors.toCollection(ArrayList::new)));
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.stream.Collectors;
class Main {
static Collection<Main> list = null;
static ArrayList create() {
return new ArrayList();
}
public static void main(String[] args) {
Collections.unmodifiableList(list.stream().collect(Collectors.toCollection(Main::create)));
}
}
- duplicates
-
JDK-8173176 javac inference failure when using implicit lambdas or inexact method references
- Closed
- is blocked by
-
JDK-8039222 5.1.10: Define glb for non-class types
- Open
- relates to
-
JDK-8170830 18.5.2: Allow stuck lambdas to be reduced before target type constraint
- Open
-
JDK-8069544 18.5.2: Define method invocation compatibility without forcing lambdas to be checked
- Closed
-
JDK-8069545 javac, shouldn't check nested stuck lambdas during overload resolution
- Closed