Mojang / DataFixerUpper

A set of utilities designed for incremental building, merging and optimization of data transformations.
MIT License
1.19k stars 138 forks source link

Identical lambda expression not garanteed by spec to be equal #79

Open TheLastRar opened 1 year ago

TheLastRar commented 1 year ago

https://docs.oracle.com/javase/specs/jls/se17/html/jls-15.html#jls-15.27.4

This implies that the identity of the result of evaluating a lambda expression (or, of serializing and deserializing a lambda expression) is unpredictable, and therefore identity-sensitive operations (such as reference equality (§15.21.3), object locking (§14.19), and the System.identityHashCode method) may produce different results in different implementations of the Java programming language, or even upon different lambda expression evaluations in the same implementation.

Yet this behaviour is relied upon in the hashCode/equals functions in TypeRewriteRule.OrElse

This was found when testing Minecraft 1.13.21 on IKVM, an alternative JVM https://github.com/ikvmnet/ikvm/issues/342