Fwd: hg: lambda/lambda/langtools: Enhancement: more stable serialized lambda names

Brian Goetz brian.goetz at oracle.com
Mon Mar 11 11:49:49 PDT 2013


Fixed as suggested.

On 3/8/2013 10:32 AM, Daniel Heidinga wrote:
> "Method names are further constrained so that, with the exception of the
> special method names <init> and <clinit> (§2.9), they must not contain the
> (Unicode code points corresponding to the) ASCII characters '<' or '>'."
> -- JVMS 4.2.2 Unqualified Names
>
> There are two special cases that this naming system falls down on:
> static initializers and constructors.   The names <clinit> & <init> will
> need to be changed when forming the 'lambda$mmm$kkkk$nnn' method name.
>   I like the following remapping: <clint> -> 'static' & <init> -> 'new'.
>
> ========== BadLambdaName.java ==========
> import java.io.Serializable;
> import java.util.concurrent.Callable;
>
> public class BadLambdaName {
> public static Callable<String> staticPublicLambda;
> Callable<String> constructorLambda;
>
> static {
> staticPublicLambda = (Callable<String> & Serializable) () -> { return
> "staticPublicLambda"; };
> }
>
> public BadLambdaName() {
> constructorLambda = (Callable<String> & Serializable) () -> { return
> "constructorLambda"; };
> }
>
>
> public static void main(String[] args) {
> throw new Error("Class should not have verified");
> }
> }
> ===================================
>
> Generates the following illegal names:
> private static java.lang.String lambda$<init>$39797$0() throws
> java.lang.Exception;
> private static java.lang.String lambda$<clinit>$39797$0() throws
> java.lang.Exception;
>
> --Dan
>
> Inactive hide details for Brian Goetz ---02/07/2013 02:36:56 PM---This
> is now implemented. The more complex convention is onlyBrian Goetz
> ---02/07/2013 02:36:56 PM---This is now implemented.  The more complex
> convention is only used for  serializable lambdas.
>
>
>     From:
>
> 	
> Brian Goetz <brian.goetz at oracle.com>
>
>     To:
>
> 	
> "lambda-spec-experts at openjdk.java.net"
> <lambda-spec-experts at openjdk.java.net>
>
>     Date:
>
> 	
> 02/07/2013 02:36 PM
>
>     Subject:
>
> 	
> Fwd: hg: lambda/lambda/langtools: Enhancement: more stable serialized
> lambda names
>
>     Sent by:
>
> 	
> lambda-spec-experts-bounces at openjdk.java.net
>
> ------------------------------------------------------------------------
>
>
>
> This is now implemented.  The more complex convention is only used for
> serializable lambdas.
>
>
> -------- Original Message --------
> Subject: hg: lambda/lambda/langtools: Enhancement: more stable
> serialized lambda names
> Date: Thu, 07 Feb 2013 19:30:41 +0000
> From: maurizio.cimadamore at oracle.com
> To: lambda-dev at openjdk.java.net
>
> Changeset: 7bffb45844fb
> Author:    mcimadamore
> Date:      2013-02-07 19:30 +0000
> URL:
> http://hg.openjdk.java.net/lambda/lambda/langtools/rev/7bffb45844fb
>
> Enhancement: more stable serialized lambda names
>
> Serializable lambdas are desugared to methods where name follows
> following pattern:
>
>    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,
> dependencies on lambdas from other methods will be minimized.
>
> ! src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java
> ! src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java
>
>
>
>
>
>


More information about the lambda-spec-experts mailing list