Details
-
Bug
-
Resolution: Fixed
-
P4
-
8, 9
-
b93
-
x86_64
-
windows_7
-
Verified
Backports
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8280974 | openjdk8u332 | Srikanth Adayapalam | P4 | Resolved | Fixed | b02 |
JDK-8298898 | shenandoah8u332 | Srikanth Adayapalam | P4 | Resolved | Fixed | master |
JDK-8279318 | 8u331 | Evan Whelan | P4 | Resolved | Fixed | b02 |
JDK-8280758 | 8u321 | Srikanth Adayapalam | P4 | Closed | Fixed | b33 |
JDK-8281576 | na | Srikanth Adayapalam | P4 | Resolved | Duplicate |
Description
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
At runtime I get a java.lang.BootstrapMethodError which is caused by a java.lang.invoke.LambdaConversionException
Basically, I have a type T extends Enum<T> & Supplier<K>
and then use a method reference which refers to the Supplier's "get" method, i.e. T::get
Note: since this error occurs at run-time & involves java.lang.invoke, I filed the issue against java.lang, but it may well be that the actual issue is in the compiler.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and execute the attached test case
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
A single line of output
ACTUAL -
An exception is thrown
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.time.LocalDate;
import java.util.EnumSet;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Function;
import java.util.function.Supplier;
public class Issue {
public static void main(String[] args) {
System.out.println(valueOfKey(Size.class, LocalDate.now()));
}
enum Size implements Supplier<LocalDate> {
S, M, L;
@Override
public LocalDate get() {
return LocalDate.now();
}
}
public static <K, T extends Enum<T> & Supplier<K>> Optional<T> valueOfKey(Class<T> enumType, K key) {
return valueOf(enumType, key, T::get);
}
public static <K, T extends Enum<T>> Optional<T> valueOf(Class<T> enumType, K key, Function<T, K> keyExtractor) {
return EnumSet.allOf(enumType)
.stream()
.filter(t -> Objects.equals(keyExtractor.apply(t), key))
.findFirst();
}
}
---------- END SOURCE ----------
Attachments
Issue Links
- backported by
-
JDK-8279318 java.lang.invoke.LambdaConversionException: Invalid receiver type ...
- Resolved
-
JDK-8280974 java.lang.invoke.LambdaConversionException: Invalid receiver type ...
- Resolved
-
JDK-8281576 java.lang.invoke.LambdaConversionException: Invalid receiver type ...
- Resolved
-
JDK-8298898 java.lang.invoke.LambdaConversionException: Invalid receiver type ...
- Resolved
-
JDK-8280758 java.lang.invoke.LambdaConversionException: Invalid receiver type ...
- Closed
- relates to
-
JDK-8268426 java.lang.invoke.LambdaConversionException: Invalid receiver type class java.lang.Object; not a subtype of implementation type
- Closed
-
JDK-8142476 Call site initialization exception caused by LambdaConversionException: Invalid receiver type
- Closed