Test serviceability/dcmd/vm/ClassLoaderStatsTest.java fails, with non-findable classes, when testing the dcmd VM.classloader_stats. It fails because the dcmd implementation in classLoaderStats.cpp does not find any short-lived classes. (A class is short-lived if it is either a JVM unsafe anonymous class or a weak non-findable class.)
The dcmd implementation looks for short-lived classes by checking if the classLoaderData is short-lived. If so, then it adds to its _anon_classes_count, _anon_chunk_sz, and _anon_block_sz statistics.
Unfortunately, the test tries to use a lambda form to create an anonymous class. But this now creates a strong non-findable class, which does not have a short-lived classLoaderData. So, the _anon_classes_count is 0, instead of the expected 1, and the test fails. (The test passes if weak non-findable classes are created instead of strong ones.)
Some issues for dcmd:
1. Should dcmd VM.classloader_stats only collect stats on weak non-findable classes? Collecting stats on strong non-findable classes would require searching all the classes in the classLoaders to see which classes ones are non-findable.
2. If dcmd does collect stats on strong non-findable classes then what does it do about fields such as _anon_chunk_sz and _anon_block_sz for the strong non-findable classes?
3. Should dcmd now keep classloader_stats on three different classes: regular, strong non-findable, and non-findable?
4. Does the test need to be changed to create a weak non-findable class?
5. Why are lambda forms now creating strong non-findable classes instead of weak ones?