@@ -420,12 +420,10 @@ void ConstantPool::remove_unshareable_info() {
420
420
// we always set _on_stack to true to avoid having to change _flags during runtime.
421
421
_flags |= (_on_stack | _is_shared);
422
422
423
- // FIXME-hack
424
- if (CDSPreimage == nullptr ) {
425
423
if (!ArchiveBuilder::current ()->get_source_addr (_pool_holder)->is_linked ()) {
426
424
return ;
427
425
}
428
- }
426
+
429
427
if (is_for_method_handle_intrinsic ()) {
430
428
// This CP was created by Method::make_method_handle_intrinsic() and has nothing
431
429
// that need to be removed/restored. It has no cpCache since the intrinsic methods
@@ -447,12 +445,14 @@ void ConstantPool::remove_unshareable_info() {
447
445
}
448
446
449
447
void ConstantPool::archive_entries () {
450
- InstanceKlass* src_holder = ArchiveBuilder::current ()->get_source_addr (_pool_holder );
448
+ InstanceKlass* src_holder = ArchiveBuilder::current ()->get_source_addr (pool_holder () );
451
449
assert (src_holder->is_linked (), " must be" );
452
450
ResourceMark rm;
453
451
GrowableArray<bool > keep_cpcache (cache ()->length (), cache ()->length (), false );
454
452
bool archived = false ;
455
453
int method_cpcache_index = 0 ; // cpcache index for Methodref/InterfaceMethodref
454
+ bool preresolve = pool_holder ()->is_shared_boot_class () || pool_holder ()->is_shared_platform_class () ||
455
+ pool_holder ()->is_shared_app_class ();
456
456
for (int cp_index = 1 ; cp_index < length (); cp_index++) { // cp_index 0 is unused
457
457
int cp_tag = tag_at (cp_index).value ();
458
458
switch (cp_tag) {
@@ -473,19 +473,30 @@ void ConstantPool::archive_entries() {
473
473
tag_at_put (cp_index, JVM_CONSTANT_Dynamic);
474
474
break ;
475
475
case JVM_CONSTANT_Class:
476
- archived = maybe_archive_resolved_klass_at (cp_index);
476
+ if (preresolve) {
477
+ archived = maybe_archive_resolved_klass_at (cp_index);
478
+ } else {
479
+ archived = false ;
480
+ }
481
+ if (!archived) {
482
+ // This referenced class cannot be archived. Revert the tag to UnresolvedClass,
483
+ // so that the proper class loading and initialization can happen at runtime.
484
+ int resolved_klass_index = klass_slot_at (cp_index).resolved_klass_index ();
485
+ resolved_klasses ()->at_put (resolved_klass_index, nullptr );
486
+ tag_at_put (cp_index, JVM_CONSTANT_UnresolvedClass);
487
+ }
477
488
ArchiveBuilder::alloc_stats ()->record_klass_cp_entry (archived);
478
489
break ;
479
490
case JVM_CONSTANT_Methodref:
480
- if (ArchiveMethodReferences) {
491
+ if (ArchiveMethodReferences && preresolve ) {
481
492
archived = maybe_archive_resolved_method_ref_at (cp_index, method_cpcache_index, cp_tag);
482
493
} else {
483
494
archived = false ;
484
495
}
485
496
ArchiveBuilder::alloc_stats ()->record_method_cp_entry (archived);
486
497
break ;
487
498
case JVM_CONSTANT_InterfaceMethodref:
488
- archived = false ;
499
+ archived = false ; // FIXME: TODO
489
500
ArchiveBuilder::alloc_stats ()->record_method_cp_entry (archived);
490
501
break ;
491
502
default :
@@ -510,6 +521,7 @@ void ConstantPool::archive_entries() {
510
521
}
511
522
}
512
523
524
+ #if 0
513
525
static const char* get_type(Klass* buffered_k) {
514
526
const char* type;
515
527
Klass* src_k = ArchiveBuilder::current()->get_source_addr(buffered_k);
@@ -537,6 +549,7 @@ static const char* get_type(Klass* buffered_k) {
537
549
538
550
return type;
539
551
}
552
+ #endif
540
553
541
554
bool ConstantPool::maybe_archive_resolved_klass_at (int cp_index) {
542
555
assert (ArchiveBuilder::current ()->is_in_buffer_space (this ), " must be" );
@@ -560,19 +573,22 @@ bool ConstantPool::maybe_archive_resolved_klass_at(int cp_index) {
560
573
if (ClassPrelinker::can_archive_resolved_klass (src_cp, cp_index)) {
561
574
if (log_is_enabled (Debug, cds, resolve)) {
562
575
ResourceMark rm;
576
+ #if 0
577
+ // FIXME: get_type() fails with runtime/cds/appcds/loaderConstraints/DynamicLoaderConstraintsTest.java
563
578
log_debug(cds, resolve)("archived klass CP entry [%3d]: %s %s => %s %s%s", cp_index,
564
579
get_type(pool_holder()), pool_holder()->name()->as_C_string(),
565
580
get_type(k), k->name()->as_C_string(),
566
581
pool_holder()->is_subtype_of(k) ? "" : " (not supertype)");
582
+ #else
583
+ log_debug (cds, resolve)(" archived klass CP entry [%3d]: %s => %s%s" , cp_index,
584
+ pool_holder ()->name ()->as_C_string (),
585
+ k->name ()->as_C_string (),
586
+ pool_holder ()->is_subtype_of (k) ? " " : " (not supertype)" );
587
+ #endif
567
588
}
568
589
return true ;
569
590
}
570
591
}
571
-
572
- // This referenced class cannot be archived. Revert the tag to UnresolvedClass,
573
- // so that the proper class loading and initialization can happen at runtime.
574
- resolved_klasses ()->at_put (resolved_klass_index, nullptr );
575
- tag_at_put (cp_index, JVM_CONSTANT_UnresolvedClass);
576
592
return false ;
577
593
}
578
594
0 commit comments