-
Bug
-
Resolution: Unresolved
-
P3
-
9
-
Fix Understood
The conversions allowed by LambdaMetafactory on parameter and return types are ad hoc and inconsistent with the specification.
Propose standardizing on the conversions supported by MethodHandle.asType, which are similar but a little more flexible.
Specifically:
factoryType.parameterType(i) --> implementation.type().parameterType(i)
Currently: same type (but receiver can be a subtype)
Change: allow any 'asType' conversion, including boxing & unboxing
dynamicMethodType.parameterType(i) --> implementation.type().parameterType(j)
Currently: ref subtype, prim widening, or box/unbox followed by these (but receiver can't be boxed)
Change: allow conversion between arbitrary refs; allow narrowing from a supertype before unbox; allow receiver to be boxed
interfaceMethodType.parameterType(i) --> dynamicMethodType.parameterType(i)
Currently: ref supertype, prim same
Change: allow any 'asType' conversion, including boxing & unboxing
implementation.type().returnType() --> dynamicMethodType.returnType()
Currently: any type targeting void, arbitrary refs, prim widening, box+widening, unbox+widening*
Change: allow void to target a non-void type; allow narrowing from a supertype before unbox
dynamicMethodType.returnType() --> interfaceMethodType.returnType()
Currently: void->void, ref subtype, prim widening, box+widening, unbox+widening
Change: allow either to be void; allow conversion between arbitrary refs; allow narrowing from a supertype before unbox
(*Current implementation allows any reference-typed implementation return to be compatible with any expected primitive type, as long as the reference type is not a box type (if it is a box type, unbox+widening applies). This is probably a bug.)
Propose standardizing on the conversions supported by MethodHandle.asType, which are similar but a little more flexible.
Specifically:
factoryType.parameterType(i) --> implementation.type().parameterType(i)
Currently: same type (but receiver can be a subtype)
Change: allow any 'asType' conversion, including boxing & unboxing
dynamicMethodType.parameterType(i) --> implementation.type().parameterType(j)
Currently: ref subtype, prim widening, or box/unbox followed by these (but receiver can't be boxed)
Change: allow conversion between arbitrary refs; allow narrowing from a supertype before unbox; allow receiver to be boxed
interfaceMethodType.parameterType(i) --> dynamicMethodType.parameterType(i)
Currently: ref supertype, prim same
Change: allow any 'asType' conversion, including boxing & unboxing
implementation.type().returnType() --> dynamicMethodType.returnType()
Currently: any type targeting void, arbitrary refs, prim widening, box+widening, unbox+widening*
Change: allow void to target a non-void type; allow narrowing from a supertype before unbox
dynamicMethodType.returnType() --> interfaceMethodType.returnType()
Currently: void->void, ref subtype, prim widening, box+widening, unbox+widening
Change: allow either to be void; allow conversion between arbitrary refs; allow narrowing from a supertype before unbox
(*Current implementation allows any reference-typed implementation return to be compatible with any expected primitive type, as long as the reference type is not a box type (if it is a box type, unbox+widening applies). This is probably a bug.)
- blocks
-
JDK-8269121 Type inference bug with method references
- Open
-
JDK-8259491 Wrong lambda conversions involving intersection types
- Open
- relates to
-
JDK-8220612 Method reference allows unboxing without cast
- In Progress
-
JDK-8269020 Correct Java code compiles, but fails at runtime with BootstrapMethodError
- Open