Names of desugared lambdas

Brian Goetz brian.goetz at oracle.com
Fri Jan 18 18:54:09 PST 2013


We had an action item from the last meeting, which got lost in the shuffle, to revisit the naming of methods that are desugared from lambda bodies.  The current lambda$n scheme is fine for non-serializable lambdas, but at least for serializable lambdas, is too sensitive to harmless refactorings like changing the order of methods within a class file. While we know there is no perfect solution, we can choose a solution that is less obviously brittle.  This brittleness is especially an issue with libraries (like the combinators for Comparator, which, to be consistent with existing Comparator implementations in the JDK, return serialiable lambdas.)  

What I propose is this: 

  lambda$mmm$kkkk$nnn

where mmm is the method name and kkk is the hashcode of the method signature, and nnn is a sequentially assigned number.  That way, at least lambdas within a method will not have any effect on lambdas from another method.  

This isn't perfect but its better than what we have.  




More information about the lambda-spec-experts mailing list