deduplicating lambda methods

John Rose john.r.rose at
Sat Mar 3 02:12:48 UTC 2018

On Mar 2, 2018, at 5:57 PM, John Rose <john.r.rose at> wrote:
> e -> k and k::m (for constants k)

Do'oh.  I meant to say "captured variables k".  They are
only constants in the sense of being final.  But *not*
compile time constants.

Brian's condy stuff handles true compile-time constants
like Integer.MAX_VALUE.  And it might use the same
off-the-shelf shared desugar methods I mentioned

I suppose I should give examples of what cross-CU
method sharing.  Suppose the source file contains
a stereotyped lambda; pick a constant-returning one.
We can lower it several ways to either a method
reference, or a partial application (curry) of a method

() -> 42


  private static int lamb$42() { return 42; } // in local CU


curry LMF::intConstant on (42)

public static int intConstant(int x) { return x; } // in LMF


curry Integer::intValue on (42)  // use a found method


something outside the LMF,
  with MethodHandles.constant() and invokeExact

Perhaps the LMF can be used directly to do the
above curries.

— John

More information about the amber-dev mailing list