RFR: 8255493: Support for pre-generated java.lang.invoke classes in CDS dynamic archive [v8]
Yumin Qi
minqi at openjdk.java.net
Wed Apr 28 03:01:12 UTC 2021
On Tue, 27 Apr 2021 23:17:15 GMT, David Holmes <dholmes at openjdk.org> wrote:
>> Yumin Qi has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Restore filemap.[ch]pp
>
> src/hotspot/share/cds/dynamicArchive.cpp line 374:
>
>> 372: JavaThread* THREAD = JavaThread::current();
>> 373: log_info(cds, dynamic)("Regenerate lambdaform holder classes ...");
>> 374: LambdaFormInvokers::regenerate_holder_classes(THREAD);
>
> You still have not addressed the exception problem here. This call can return early with an exception pending due to line 89 in the called method, which uses CHECK. That exception will escape up to the Java code after the VM operation completes.
>
> Note: If `regenerate_holder_classes` is changed to suppress all exceptions then it should not be declared TRAPS and there is no need to pass THREAD (manifest [Java]Thread::current() internally as needed).
Thanks for pointing this out, I checked the function LambdaFormInvokers::regenerate_holder_classes again. Looks the TRAPS can be removed. There are two cases:
1) If any allocation failed due to OOM, vm will exit except for the line 124:
char *buf = resource_allocate_bytes(THREAD, len, AllocFailStrategy::RETURN_NULL);
if (buf == nullptr) {
log_info(cds)("Out of memory when reloading class %s, quit", class_name);
return;
}
2) CDS.generateLambdaFormHolderClasses may throw exception, the exception is supressed inside the function.
So I will remove the TRAPS.
> src/hotspot/share/cds/lambdaFormInvokers.cpp line 185:
>
>> 183: int len = (int)strlen(str);
>> 184: Array<char>* line = ArchiveBuilder::new_ro_array<char>(len+1);
>> 185: strcpy(line->adr_at(0), str); // copies terminating zero as well
>
> Should use strncpy for safety (code checkers will flag this).
Will update with strncpy.
-------------
PR: https://git.openjdk.java.net/jdk/pull/3611
More information about the hotspot-dev
mailing list