We assert for `java -Xshare:dump -Xlog:cds*=trace`:
```
# assert(counter_check_mirror == java_class) failed: must be consistent
```
at
```
29 Stack: [0x00007f8821535000,0x00007f8821635000], sp=0x00007f8821632e80, free space=1015k
30 Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
31 V [libjvm.so+0xda0155] java_lang_Class::primitive_type(oopDesc*)+0x13d (javaClasses.cpp:1367)
32 V [libjvm.so+0xd9fb95] java_lang_Class::print_signature(oopDesc*, outputStream*)+0x9f (javaClasses.cpp:1284)
33 V [libjvm.so+0xd623f5] InstanceKlass::oop_print_on(oopDesc*, outputStream*)+0x175 (instanceKlass.cpp:3652)
34 V [libjvm.so+0x127ec71] oopDesc::print_on(outputStream*) const+0x9f (oop.cpp:47)
35 V [libjvm.so+0xd34621] void WalkOopAndArchiveClosure::do_oop_work<narrowOop>(narrowOop*)+0x1e1 (heapShared.cpp:1124)
36 V [libjvm.so+0xd33261] WalkOopAndArchiveClosure::do_oop(narrowOop*)+0x27 (heapShared.cpp:1107)
37 V [libjvm.so+0xd31cbe] EnableIf<!std::is_same<WalkOopAndArchiveClosure, OopClosure>::value, void>::type call_do_oop<narrowOop, WalkOopAndArchiveClosure, OopClosure, WalkOopAndArchiveClosure>(void (WalkOopAndArchiveClosure::*)(narrowOop*), void (OopClosure::*)(narrowOop *), WalkOopAndArchiveClosure*, narrowOop*)+0x46 (devirtualizer.inline.hpp:88)
38 V [libjvm.so+0xd3b99d] void Devirtualizer::do_oop<WalkOopAndArchiveClosure, narrowOop>(WalkOopAndArchiveClosure*, narrowOop*)+0x4b (devirtualizer.inline.hpp:93)
39 V [libjvm.so+0xd38129] void InstanceMirrorKlass::oop_oop_iterate<narrowOop, WalkOopAndArchiveClosure>(oopDesc*, WalkOopAndArchiveClosure*)+0x13d (instanceKlass.inline.hpp:97)
40 V [libjvm.so+0xd37192] void OopOopIterateDispatch<WalkOopAndArchiveClosure>::Table::oop_oop_iterate<InstanceMirrorKlass, narrowOop>(WalkOopAndArchiveClosure*, oopDesc*, Klass*)+0x2f (iterator.inline.hpp:110)
41 V [libjvm.so+0xd354db] void OopIteratorClosureDispatch::oop_oop_iterate<WalkOopAndArchiveClosure>(WalkOopAndArchiveClosure*, oopDesc*, Klass*)+0x35 (iterator.inline.hpp:295)
42 V [libjvm.so+0xd349ca] void oopDesc::oop_iterate<WalkOopAndArchiveClosure>(WalkOopAndArchiveClosure*)+0x36 (oop.inline.hpp:318)
43 V [libjvm.so+0xd2f920] HeapShared::archive_reachable_objects_from(int, KlassSubGraphInfo*, oopDesc*)+0x2d4 (heapShared.cpp:1211)
44 V [libjvm.so+0xd2caeb] HeapShared::archive_java_mirrors()+0x2a9 (heapShared.cpp:395)
45 V [libjvm.so+0xd2d842] HeapShared::copy_special_objects()+0x12 (heapShared.cpp:567)
46 V [libjvm.so+0xd2d8bb] HeapShared::copy_objects()+0x6b (heapShared.cpp:576)
47 V [libjvm.so+0xd2d68c] HeapShared::archive_objects(ArchiveHeapInfo*)+0xfe (heapShared.cpp:538)
48 V [libjvm.so+0x11de094] VM_PopulateDumpSharedSpace::dump_java_heap_objects(GrowableArray<Klass*>*)+0x188 (metaspaceShared.cpp:855)
49 V [libjvm.so+0x11dd06c] VM_PopulateDumpSharedSpace::doit()+0xea (metaspaceShared.cpp:510)
50 V [libjvm.so+0x166d3f6] VM_Operation::evaluate()+0xde (vmOperations.cpp:71)
51 V [libjvm.so+0x16d71f5] VMThread::evaluate_operation(VM_Operation*)+0xdf (vmThread.cpp:281)
52 V [libjvm.so+0x16d7b57] VMThread::inner_execute(VM_Operation*)+0x343 (vmThread.cpp:428)
53 V [libjvm.so+0x16d7f4d] VMThread::loop()+0x135 (vmThread.cpp:495)
54 V [libjvm.so+0x16d6d36] VMThread::run()+0xfe (vmThread.cpp:175)
55 V [libjvm.so+0x15bcca0] Thread::call_run()+0x1a8 (thread.cpp:217)
56 V [libjvm.so+0x129f358] thread_native_entry(Thread*)+0x1a5 (os_linux.cpp:775)
```
The reason is that, when tracing with trace level, we print each copied oop in full, including the basic java mirrors. As part of the trace, we print the basic type. That function `BasicType java_lang_Class::primitive_type(oop java_class)` does a sanity check: the printed oop, that is supposed to be a class mirror for a basic type, must be the same as the oop resolved via (this oop)->array_klass->element_type->mirror for that type).
We crash when printing the mirror for "int" because there are two mirrors for int at this point: the one in `Universe::_basic_type_mirrors`, and the one in `HeapShared::_scratch_basic_type_mirrors`.
```
# assert(counter_check_mirror == java_class) failed: must be consistent
```
at
```
29 Stack: [0x00007f8821535000,0x00007f8821635000], sp=0x00007f8821632e80, free space=1015k
30 Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
31 V [libjvm.so+0xda0155] java_lang_Class::primitive_type(oopDesc*)+0x13d (javaClasses.cpp:1367)
32 V [libjvm.so+0xd9fb95] java_lang_Class::print_signature(oopDesc*, outputStream*)+0x9f (javaClasses.cpp:1284)
33 V [libjvm.so+0xd623f5] InstanceKlass::oop_print_on(oopDesc*, outputStream*)+0x175 (instanceKlass.cpp:3652)
34 V [libjvm.so+0x127ec71] oopDesc::print_on(outputStream*) const+0x9f (oop.cpp:47)
35 V [libjvm.so+0xd34621] void WalkOopAndArchiveClosure::do_oop_work<narrowOop>(narrowOop*)+0x1e1 (heapShared.cpp:1124)
36 V [libjvm.so+0xd33261] WalkOopAndArchiveClosure::do_oop(narrowOop*)+0x27 (heapShared.cpp:1107)
37 V [libjvm.so+0xd31cbe] EnableIf<!std::is_same<WalkOopAndArchiveClosure, OopClosure>::value, void>::type call_do_oop<narrowOop, WalkOopAndArchiveClosure, OopClosure, WalkOopAndArchiveClosure>(void (WalkOopAndArchiveClosure::*)(narrowOop*), void (OopClosure::*)(narrowOop *), WalkOopAndArchiveClosure*, narrowOop*)+0x46 (devirtualizer.inline.hpp:88)
38 V [libjvm.so+0xd3b99d] void Devirtualizer::do_oop<WalkOopAndArchiveClosure, narrowOop>(WalkOopAndArchiveClosure*, narrowOop*)+0x4b (devirtualizer.inline.hpp:93)
39 V [libjvm.so+0xd38129] void InstanceMirrorKlass::oop_oop_iterate<narrowOop, WalkOopAndArchiveClosure>(oopDesc*, WalkOopAndArchiveClosure*)+0x13d (instanceKlass.inline.hpp:97)
40 V [libjvm.so+0xd37192] void OopOopIterateDispatch<WalkOopAndArchiveClosure>::Table::oop_oop_iterate<InstanceMirrorKlass, narrowOop>(WalkOopAndArchiveClosure*, oopDesc*, Klass*)+0x2f (iterator.inline.hpp:110)
41 V [libjvm.so+0xd354db] void OopIteratorClosureDispatch::oop_oop_iterate<WalkOopAndArchiveClosure>(WalkOopAndArchiveClosure*, oopDesc*, Klass*)+0x35 (iterator.inline.hpp:295)
42 V [libjvm.so+0xd349ca] void oopDesc::oop_iterate<WalkOopAndArchiveClosure>(WalkOopAndArchiveClosure*)+0x36 (oop.inline.hpp:318)
43 V [libjvm.so+0xd2f920] HeapShared::archive_reachable_objects_from(int, KlassSubGraphInfo*, oopDesc*)+0x2d4 (heapShared.cpp:1211)
44 V [libjvm.so+0xd2caeb] HeapShared::archive_java_mirrors()+0x2a9 (heapShared.cpp:395)
45 V [libjvm.so+0xd2d842] HeapShared::copy_special_objects()+0x12 (heapShared.cpp:567)
46 V [libjvm.so+0xd2d8bb] HeapShared::copy_objects()+0x6b (heapShared.cpp:576)
47 V [libjvm.so+0xd2d68c] HeapShared::archive_objects(ArchiveHeapInfo*)+0xfe (heapShared.cpp:538)
48 V [libjvm.so+0x11de094] VM_PopulateDumpSharedSpace::dump_java_heap_objects(GrowableArray<Klass*>*)+0x188 (metaspaceShared.cpp:855)
49 V [libjvm.so+0x11dd06c] VM_PopulateDumpSharedSpace::doit()+0xea (metaspaceShared.cpp:510)
50 V [libjvm.so+0x166d3f6] VM_Operation::evaluate()+0xde (vmOperations.cpp:71)
51 V [libjvm.so+0x16d71f5] VMThread::evaluate_operation(VM_Operation*)+0xdf (vmThread.cpp:281)
52 V [libjvm.so+0x16d7b57] VMThread::inner_execute(VM_Operation*)+0x343 (vmThread.cpp:428)
53 V [libjvm.so+0x16d7f4d] VMThread::loop()+0x135 (vmThread.cpp:495)
54 V [libjvm.so+0x16d6d36] VMThread::run()+0xfe (vmThread.cpp:175)
55 V [libjvm.so+0x15bcca0] Thread::call_run()+0x1a8 (thread.cpp:217)
56 V [libjvm.so+0x129f358] thread_native_entry(Thread*)+0x1a5 (os_linux.cpp:775)
```
The reason is that, when tracing with trace level, we print each copied oop in full, including the basic java mirrors. As part of the trace, we print the basic type. That function `BasicType java_lang_Class::primitive_type(oop java_class)` does a sanity check: the printed oop, that is supposed to be a class mirror for a basic type, must be the same as the oop resolved via (this oop)->array_klass->element_type->mirror for that type).
We crash when printing the mirror for "int" because there are two mirrors for int at this point: the one in `Universe::_basic_type_mirrors`, and the one in `HeapShared::_scratch_basic_type_mirrors`.