RFR: 8276184: Exclude lambda proxy class from the CDS archive if its caller class is excluded [v3]

Ioi Lam iklam at openjdk.java.net
Thu Nov 11 01:43:37 UTC 2021


On Mon, 8 Nov 2021 05:00:57 GMT, Calvin Cheung <ccheung at openjdk.org> wrote:

>> src/hotspot/share/classfile/systemDictionaryShared.cpp line 1626:
>> 
>>> 1624:     for (int i = 0; i < info._proxy_klasses->length(); i++) {
>>> 1625:       InstanceKlass* ik = info._proxy_klasses->at(i);
>>> 1626:       if (SystemDictionaryShared::check_for_exclusion_impl(ik, true)) {
>> 
>> With the original code, if the list has two elements, only the first one is removed -- after the first iteration, `i` becomes 1, but `_proxy_klasses->length()` is also 1, and thus the loop will terminate.
>> 
>> I think the loop should be reversed:
>> 
>> for (int i = info._proxy_klasses->length() - 1; i >= 0; i--) {
>>   if (...) {
>>     info._proxy_klasses->remove_at(i);
>>   }
>> }
>> 
>> 
>> For test coverage, we should also have two test case:
>> 
>> - caller class Foo1 that uses a single instance of an lambda based on old interface
>> - caller class Foo2 that uses two instances of an lambda based on old interface
>
> Nice catch! I've fixed the code.
> I've expanded the existing LambdaContainsOldInf.java test to cover the above cases.

Related to David's comments, I think we can change the check_for_exclusion_impl() calls in this function to avoid adding the `silent` parameter. How about:


- if (SystemDictionaryShared::check_for_exclusion_impl(caller_ik, true)) {
+ if (!SystemDictionaryShared::check_for_exclusion(caller_ik, NULL)) {
...
- if (SystemDictionaryShared::check_for_exclusion_impl(ik, true)) {
- if (!SystemDictionaryShared::check_for_exclusion(ik, NULL)) {


The reason to check for `caller_ik` is that -- if `ik` is archived, then `caller_ik` must be also archived.

For the `caller_ik` check in the dynamic dump case, if the `caller_ik` is in the base shared archive, we know that it has been archived, so it's OK to archive `ik`.

Since all the calls are going through `SystemDictionaryShared::check_for_exclusion()`, we can be sure the exclusion warning message is printed at most once for each class.

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

PR: https://git.openjdk.java.net/jdk/pull/6205


More information about the hotspot-runtime-dev mailing list