Updated State of the Specialization
Brian Goetz
brian.goetz at oracle.com
Sun Dec 21 16:07:28 UTC 2014
Value types need to have some form of at least some of the core Object
methods, at least hashCode, equals, and toString. Open questions here
include:
- Will there be some interface that specifies these? (C# has a root
interfaces like this that all structs implement)
- Will Object implement that interface? (Seems nice for generic code,
but then it can't be called anything Value-ish, would have to be called
Object-ish, like "Objectionable" or "Objectifiable" or
"ObjectionYourHonor".)
The compiler or VM would certainly generate default implementations of
equals/hashCode that delegates to the components. A further open
question is whether these could be overridden by value types, or whether
this is just part of their definition. (And, if equals/hashCode are
effectively final, its a little weird for toString to be standing alone,
though would be permissible.)
On 12/21/2014 10:54 AM, Gustav Åkesson wrote:
> Hi,
>
> I'm going through the nitty-gritty details of this super exciting
> proposal, but one question came to mind which I couldn't find an
> explanation for in the proposal. If we have...
>
>
> class Summerizer<any T> {
>
> int sumHashCodes(T ... entries) {
>
> // Sum hash code values for all entries using ::hashCode()
>
> }
>
> }
>
> ...then how will the specialized class for Summerizer<int> know that the
> same semantics as Integer::hashCode() should be inferred here? Same goes
> for the other primitive types.
>
> I'm thinking of e.g. equals as well. Using synchronized on the type
> could be prohibited (as stated by the Language restriction section), but
> what above methods inherited from Object?
>
>
> Best Regards,
>
> Gustav Åkesson
>
>
> On Fri, Dec 19, 2014 at 10:31 PM, Brian Goetz <brian.goetz at oracle.com
> <mailto:brian.goetz at oracle.com>> wrote:
>
> I've updated the State of the Specialization here:
> http://cr.openjdk.java.net/~__briangoetz/valhalla/__specialization.html
> <http://cr.openjdk.java.net/~briangoetz/valhalla/specialization.html>
>
> The old version is here:
> http://cr.openjdk.java.net/~__briangoetz/valhalla/__specialization-1.html
> <http://cr.openjdk.java.net/~briangoetz/valhalla/specialization-1.html>
>
>
More information about the valhalla-dev
mailing list