JDK-8016207 : Widening of capture vars occurs at unspecified times
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2013-06-07
  • Updated: 2019-05-08
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.
Other
tbd_majorUnresolved
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
javac's treatment of capture is often inconsistent with the specification.  Sometimes capture occurs in places other than where it is specified.  Sometimes a capture variable is "widened" to its upper bound.

The changes necessary to match the specification seem to run pretty deep; there doesn't seem to be an easy quick fix.

There may be some value in javac's behavior; if so, it should be identified and pushed back into the specification.
Comments
One example from Attr.visitForEachLoop: Type exprType = types.cvarUpperBound(attribExpr(tree.expr, loopEnv))
14-12-2015