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

Mandy Chung mchung at openjdk.org
Fri Oct 14 17:15:00 UTC 2022


On Fri, 14 Oct 2022 16:57:47 GMT, Mandy Chung <mchung at openjdk.org> wrote:

>> Ioi Lam has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   @iwanowww comments
>
> src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java line 291:
> 
>> 289:         final List<ClassData> cd = classData;
>> 290:         return switch(cd.size()) {
>> 291:             case 0 -> null;
> 
> `List.of()` always returns the same singleton instance and does not cause any object allocation.  I prefer to keep the `classDataValues()` to return `List<Object>`

Ah, I now see why you have to change the signature because of the single element case.  I made my comment too quickly. 

A couple of suggestions:
Please add a javadoc for this method to describe what this method returns for different cases.   It's better to move this method close to `clinit` as they are tightly coupled.

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

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


More information about the core-libs-dev mailing list