RFR: 8295302: Do not use ArrayList when LambdaForm has a single ClassData [v3]
Mandy Chung
mchung at openjdk.org
Tue Oct 18 17:49:08 UTC 2022
On Tue, 18 Oct 2022 05:21:47 GMT, Ioi Lam <iklam at openjdk.org> wrote:
>> 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`.
yes, it's an internal version that defines a hidden class, equivalent to calling `Lookup::defineHiddenClassWithClassData` (typo in my suggested wording), but it will bypass the security permission check and also returns the Class instead of Lookup (saving not to allocate a Lookup object).
-------------
PR: https://git.openjdk.org/jdk/pull/10706
More information about the core-libs-dev
mailing list