RFR: 8292914: Drop the counter from lambda class names [v8]
Mandy Chung
mchung at openjdk.org
Thu Feb 23 23:54:12 UTC 2023
On Fri, 17 Feb 2023 19:37:59 GMT, David M. Lloyd <duke at openjdk.org> wrote:
>> The class generated for lambda proxies is now defined as a hidden class. This means that the counter, which was used to ensure a unique class name and avoid clashes, is now redundant. In addition to performing redundant work, this also impacts build reproducibility for native image generators which might already have a strategy to cope with hidden classes but cannot cope with indeterminate definition order for lambda proxy classes.
>>
>> This solves JDK-8292914 by making lambda proxy names always be stable without any configuration needed. This would also replace #10024.
>
> David M. Lloyd has updated the pull request incrementally with two additional commits since the last revision:
>
> - Many tests have patterns for lambda class names; update them
> - Update comments and javadoc showin the old pattern
src/java.base/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java line 370:
> 368: if (useImplMethodHandle) {
> 369: lookup = caller.defineHiddenClassWithClassData(classBytes, implementation, !disableEagerInitialization,
> 370: NESTMATE, STRONG);
nit: formatting - align this line to the first argument `classBytes` in L369.
src/java.base/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java line 374:
> 372: lookup = caller.defineHiddenClass(classBytes, !disableEagerInitialization, NESTMATE, STRONG);
> 373: }
> 374: } catch (Throwable t) {
suggest to use try-finally in writing the file.
Lookup lookup = null;
try {
if (useImplMethodHandle) {
lookup = caller.defineHiddenClassWithClassData(classBytes, implementation, !disableEagerInitialization,
NESTMATE, STRONG);
} else {
lookup = caller.defineHiddenClass(classBytes, !disableEagerInitialization, NESTMATE, STRONG);
}
} finally {
// If requested, dump out to a file for debugging purposes
if (dumper != null) {
final String name;
if (lookup != null) {
String definedName = lookup.lookupClass().getName();
int suffixIdx = definedName.lastIndexOf('/');
assert suffixIdx != -1;
name = lambdaClassName + '.' + definedName.substring(suffixIdx + 1);
} else {
name = lambdaClassName + ".failed-" + counter.incrementAndGet();
}
doDump(name, classBytes);
}
}
return lookup.lookupClass();
-------------
PR: https://git.openjdk.org/jdk/pull/12579
More information about the core-libs-dev
mailing list