RFR: 8295302: Do not use ArrayList when LambdaForm has a single ClassData [v3]

Ioi Lam iklam at openjdk.org
Tue Oct 18 05:24:00 UTC 2022


On Tue, 18 Oct 2022 02:03:06 GMT, Mandy Chung <mchung at openjdk.org> wrote:

>> Ioi Lam has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains four additional commits since the last revision:
>> 
>>  - Merge branch 'master' into 8295302-no-arraylist-for-single-classdata-for-lambdaform
>>  - @mlchung comments
>>  - @iwanowww comments
>>  - 8295302: Do not use ArrayList when LambdaForm has a single ClassData
>
> src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java line 346:
> 
>> 344: 
>> 345:     /**
>> 346:      * Returns an object to pass this.classData to the <clinit> method of the
> 
> What about:
> 
> Suggestion:
> 
>      * Returns the class data object that will be passed to `Lookup.defineHiddenClass`.
>      * The classData is loaded in the <clinit> method of the generated class.
>      * If the class data contains only one single object, this method returns  that single object.
>      * If the class data contains more than one objects, this method returns a List.
>      *
>      * This method returns null if no class data.

Actually, the classData is passed here:


    private MemberName loadMethod(byte[] classFile) {
        Class<?> invokerClass = LOOKUP.makeHiddenClassDefiner(className, classFile, Set.of())
                                      .defineClass(true, classDataValues());
        return resolveInvokerMember(invokerClass, invokerName, invokerType);
    }


So it doesn't go through `Lookup.defineHiddenClass`.

-------------

PR: https://git.openjdk.org/jdk/pull/10706


More information about the core-libs-dev mailing list