JDK-8027738 : Lambda Spec: Disallow arrays in intersection cast targets
  • Type: Bug
  • Component: specification
  • Sub-Component: language
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2013-11-01
  • Updated: 2017-02-17
  • Resolved: 2017-02-17
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8Fixed
Related Reports
Blocks :  
Blocks :  
Relates :  
Description
Arrays are presently allowed in intersection types, but this type is uninhabited (no such values exist in the language), and adding the ability to javac has created a bug-tail.  Therefore the spec should be amended to disallow this case.
Comments
I see this update in 0.9.0. Thanks.
24-12-2013

Unfortunately spec 0.7.0 that is last version available for us still doesn't contain updates concerning constraints on arrays in intersection cast targets. As a result lmbd118 tests based on assertions presented in 0.7.0 still fail and can not be excluded till new version of spec appears. When can we expect new version of spec containing above-mentioned updates?
22-11-2013

For consistency with 4.4, the following additional constraints should be enforced for casts, too: If the cast expression has an AdditionalBoundList, then the following conditions must hold for the listed types (including the ClassOrInterfaceType and each additional InterfaceType), or a compile-time error occurs: - The erasures (4.6) of all the listed types are pairwise different. - No two listed types are subtypes of different parameterizations of the same generic interface.
04-11-2013

It makes sense to adjust the syntax as follows, because no array can implement more interfaces than Object[]: --- [Old] CastExpression: '(' PrimitiveType ')' UnaryExpression '(' ReferenceType AdditionalBoundListopt ')' UnaryExpressionNotPlusMinus [New] CastExpression: '(' PrimitiveType ')' UnaryExpression '(' ReferenceType ')' UnaryExpressionNotPlusMinus '(' ClassOrInterfaceType AdditionalBoundList ')' UnaryExpressionNotPlusMinus --- Note that this does not imply that glb will never be performed on multiple array types: --- <T> T glb(Iterable<? super T> arg1, Iterable<? super T> arg2) { return null; } interface I {} interface J {} void test(Iterable<I[]> is, Iterable<J[]> js) { Object o = glb(is, js)[0]; // javac 7 error: actual argument Iterable<I[]> cannot be converted to Iterable<? super J[]> by method invocation conversion } --- But it seems that javac is doing something unspecified here, and that's an old problem that can probably be addressed another day...
01-11-2013

Technical correction: the types Integer[] & Serializable and Integer[] & Object are inhabited, but these types are redundant
01-11-2013

Blocks two P2's
01-11-2013