RFR: 8377777: Improve logging when rejecting methods on the archive

Andrew Dinn adinn at openjdk.org
Thu Feb 12 17:23:24 UTC 2026


On Thu, 12 Feb 2026 12:10:55 GMT, María Arias de Reyna Domínguez <duke at openjdk.org> wrote:

> Restored the check `if (resolved)` when printing if a CP entry is rejected or archived. If it is not resolved, we shouldn't even bother with it.
> 
> Also, added log messages (mostly based on surrounding comments) on `ConstantPoolCache::can_archive_resolved_method` to add information about why a method gets rejected.
> 
> All the log messages have the same format to be able to parse them easily:
> 
> ` log.print("%s can't be archived because $REASON.",
>                 pool_holder->name()->as_C_string());`

src/hotspot/share/oops/cpCache.cpp line 555:

> 553:     if (log.is_enabled()) {
> 554:       log.print("%s can't be archived because it comes from a non-builtin loader.",
> 555:                 pool_holder->name()->as_C_string());

You have identified the root problem here i.e. the pool holder class belongs to a non-builtin loader. However, the error message is recording the fact that a specific CPCache (method) entry for that class is  unable to be archived. So the log message needs to include that immediate error as well as the cause.
Suggestion:

      int cp_index = method_entry->constant_pool_index();
      int klass_cp_index = src_cp->uncached_klass_ref_index_at(cp_index);
      Symbol* klass_name = src_cp->klass_name_at(klass_cp_index);
      Symbol* name = src_cp->uncached_name_ref_at(cp_index);
      Symbol* signature = src_cp->uncached_signature_ref_at(cp_index);
      ResourceMark rm;
      log.print("%s resolved CP entry [%3d] =>%s method %s.%s:%s cannot be archived because pool holder comes from a non-builtin loader.",
                src_cp->pool_holder()->name()->as_C_string(),
                cp_index,
                (method_entry->is_resolved(Bytecodes::_invokeinterface) ? " interface" : ""),
                klass_name->as_C_string(),
                name->as_C_string(),
                signature->as_C_string());

The same thing applies for the other log messages in this method.

src/hotspot/share/oops/cpCache.cpp line 605:

> 603: 
> 604:   if (!AOTConstantPoolResolver::is_resolution_deterministic(src_cp, cp_index)) {
> 605:     if (log.is_enabled()) {

This also needs to identify the method that has been linked via the CP entry. However, note that the linkage for field and indy entries is also checked and erased (in ConstantPoolCache methods `remove_resolved_field_entries_if_non_deterministic` and `remove_resolved_indy_entries_if_non_deterministic`) when `AOTConstantPoolResolver::is_resolution_deterministic` returns true. So, a log message should be added in those two cases but this time identifying the target field or target BSM.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/29690#discussion_r2800115135
PR Review Comment: https://git.openjdk.org/jdk/pull/29690#discussion_r2800114794


More information about the hotspot-dev mailing list