toString/equals/hashCode implemented using method handles

forax at forax at
Thu Jun 21 21:41:35 UTC 2018

the meta-protocols used are not the same (currently ?),
- For records, the BSM is called with an array of method handles because a record defined an order (the order of the primary constructor)
- For value type, the BSM doesn't use any supplementary constants (yet ?)

Note that means that because the method handles are resolved eagerly (at least now *), a record can not reference a non existing class that will have it's field initialized with null.
Note2: the implementation i've provided will not resolved the classes of the field too eagerly but it will still try to load the field class even if the field is null.

I'm not sure these small differences are enough to justify to have two implementations, but the requirements are not exactly the same.


* we should restart our discussions about how to lazy resolved bootstrap constant soon.

----- Mail original -----
> De: "Brian Goetz" <brian.goetz at>
> À: "Remi Forax" <forax at>, "valhalla-spec-experts" <valhalla-spec-experts at>
> Cc: "mandy chung" <mandy.chung at>
> Envoyé: Jeudi 21 Juin 2018 22:53:57
> Objet: Re: toString/equals/hashCode implemented using method handles

>> As discussed during our today meeting,
>> here is an implementation of toString, equals and hashCode that can be used as
>> default implementation of these methods for value types.
> There is also similar code in the Amber repo for records.  At some
> point, we should have a bake-off and pick the best implementation;
> surely we should only have one.

More information about the valhalla-spec-experts mailing list