-
Bug
-
Resolution: Fixed
-
P2
-
5.0
-
None
-
rc
-
generic
-
solaris_8
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.
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.
- relates to
-
JDK-4993221 Produce infinite types from lub as required by JLS
- Open