JDK-4929881 : What is the type of b?Integer.class:Float.class
  • Type: Bug
  • Component: specification
  • Sub-Component: language
  • Affected Version: 5.0
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: solaris_8
  • CPU: generic
  • Submitted: 2003-09-29
  • Updated: 2004-07-19
  • Resolved: 2004-07-19
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
5.0 rcFixed
Related Reports
Relates :  
Description
Given b of type boolean, what is the type of the expression

	b?Integer.class:Float.class

At first glance, it might be

	Class<?>

but that's not right, as these are related classes.  Perhaps

	Class<Number>

no, they're also Comparable

	Class<Number&Comparable<?>>

but Comparable to what?  We do have some information about that...

	Class<Number&Comparable<Number&Comparable<?>>>

or deeper...

	Class<Number&Comparable<Number&Comparable<Number&Comparable<?>>>>

in fact, each of these is a more precise approximation in an infinite sequence, each of which is better than the previous.  The spec isn't very clear on this, but suggests that the answer is the limit of this sequence.  I think as a practical matter we need to cut this off somewhere.  How to do so in the spec is the hard problem.  I would like the answer to be

	Class<Number&Comparable<?>>

I chose to put the ? in the first place in an infinite recursion where the type is the same as an enclosing type.  That happens to be relatively easy to implement (though I do worry about performance)

Once I have a spec for this, I will be able to implement ?: in the compiler.

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: generic FIXED IN: tiger-rc INTEGRATED IN: tiger-rc
21-08-2004

EVALUATION The spec currently implies the limit is the solution, and the compiler can implement this with a cyclic data structure. We need to assess if this is reasonable. ###@###.### 2004-06-03 The spec gives the algorithm for computing this; it is implemented. ###@###.### 2004-07-19
03-06-2004