A library for implementing equals and hashCode

Remi Forax forax at univ-mlv.fr
Sat Apr 27 14:59:59 UTC 2019

After a hacking session, i've got your API and nice performance. 
[ https://github.com/forax/exotic/blob/master/src/test/java/com.github.forax.exotic/com/github/forax/exotic/ObjectSupportExampleTests.java#L12 | https://github.com/forax/exotic/blob/master/src/test/java/com.github.forax.exotic/com/github/forax/exotic/ObjectSupportExampleTests.java#L12 ] 

It works like this, the lambdas are declared Serializable, calling writeReplace on them give me the corresponding SerializedLambda object (i stole that idea from Tagir), which give me the class and the method that contains the lambda body, then i scan the bytecode to extract the corresponding field name (i look for the pattern aload_0 + getfield). Once i have the field name, i re-construct a method handle tree around to implement either hashCode or equals and ensure that from a JIT POV everything is a constant. 


> De: "Liam Miller-Cushon" <cushon at google.com>
> À: "amber-spec-experts" <amber-spec-experts at openjdk.java.net>
> Envoyé: Lundi 22 Avril 2019 20:29:51
> Objet: A library for implementing equals and hashCode

> Please consider this proposal for a library to help implement equals and
> hashCode.

> The doc includes a discussion of the motivation for adding such an API to the
> JDK, a map of the design space, and some thoughts on the subset of that space
> which might be most interesting:

> [ http://cr.openjdk.java.net/~cushon/amber/equivalence.html |
> http://cr.openjdk.java.net/~cushon/amber/equivalence.html ]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/amber-spec-experts/attachments/20190427/866ed54c/attachment.html>

More information about the amber-spec-experts mailing list