RFR: 8279009: CDS crashes when the source of an InstanceKlass is NULL

Ioi Lam iklam at openjdk.java.net
Fri Jan 14 06:50:27 UTC 2022


On Thu, 13 Jan 2022 22:26:24 GMT, Yumin Qi <minqi at openjdk.org> wrote:

> Please review
>   When user combine -XX:ArchiveClassesAtExit and -XX:DumpLoadedClassList, vm will generate shared archive at exit mean while dump class list to a file, it will encounter null source when lambda form invoker holder classes are regenerated which have no source.  It failed to output the NULL source.
>    The fix is simply add ing check if the source exists. 
>    For unregistered classes loaded from shared space, they should be filtered out since the source are not recorded in shared space.
> 
>    Tests: tier2,tier2.tier3,tier4
> 
> Thanks
> Yumin

VM changes look good. I have some suggestions for the test cases.

test/hotspot/jtreg/runtime/cds/appcds/ClassListWithCustomClassNoSource.java line 49:

> 47:         cw.visitEnd();
> 48:         return cw.toByteArray();
> 49:     }

There's a much simpler way to get classfile bytes without using objectweb.asm. Please see an example here:

https://github.com/openjdk/jdk/blame/09cf5f19d76b17790ffb899aad247f821a27d46b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/test-classes/LotsUnloadApp.java#L36

test/hotspot/jtreg/runtime/cds/appcds/ClassListWithInvokerClassNoSource.java line 29:

> 27: import java.lang.invoke.MethodType;
> 28: 
> 29: public class ClassListWithInvokerClassNoSource {

I think we should add comments like this to describe the purpose of this class:

// When this class is executed, the following classes will be generated by
// java.lang.invoke.ClassSpecializer with the code source
// "_ClassSpecializer_generateConcreteSpeciesCode".
//
//   - java.lang.invoke.BoundMethodHandle$Species_LFDIIL
//   - java.lang.invoke.BoundMethodHandle$Species_LFDIILJ
//   - java.lang.invoke.BoundMethodHandle$Species_LFDIILJD
//   - ...
// 
// The TestDumpClassListSource test case checks that these classes are not
// written into the classlist, as they cannot be handled by -Xshare:dump


Also, the name `ClassListWithInvokerClassNoSource` is misleading, since these classes DO have a code source, except the code source cannot be understood by -Xshare:dump.

Maybe we should rename it to something like `ClassSpecializerTestApp`, to describe what this class actually does?

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

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


More information about the hotspot-runtime-dev mailing list