RFR: 8377777: Improve logging when rejecting assets from the AOT archive [v8]

Thomas Stuefe stuefe at openjdk.org
Wed Feb 25 17:31:17 UTC 2026


On Wed, 25 Feb 2026 11:35:58 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());`
>
> María Arias de Reyna Domínguez has updated the pull request incrementally with one additional commit since the last revision:
> 
>   cleanup and fix tests

Small nits, otherwise this looks fine.

Are there any existing jtreg tests you could modify to test your change? E.g. test/hotspot/jtreg/runtime/cds/appcds/resolvedConstants/AOTLinkedVarHandles.java ?

src/hotspot/share/oops/constantPool.cpp line 313:

> 311:       for (int i = 0; i < method_entries->length(); i++) {
> 312:         ResolvedMethodEntry* rme = method_entries->adr_at(i);
> 313:         if (const char* reason; rme->is_resolved(Bytecodes::_invokehandle) && rme->has_appendix() &&

Please put reason outside the condition.

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

> 478:                     (rme->is_resolved(Bytecodes::_invokestatic) && VM_Version::supports_fast_class_init_checks());
> 479: 
> 480:     const char *reason = nullptr;

Suggestion:

    const char* reason = nullptr;

Both are valid, but the latter is commonly used in hotspot.

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

> 500:                   cp->pool_holder()->name()->as_C_string(),
> 501:                   klass_name->as_C_string(), name->as_C_string(), signature->as_C_string(),
> 502:                   (reason == nullptr ? "" : reason));

Could you try this?

Suggestion:

        LogStream ls(log);
        ls.print("%s%s method CP entry [%3d]: %s %s.%s:%s",
                (archived ? "archived" : "reverted"),
                (rme->is_resolved(Bytecodes::_invokeinterface) ? " interface" : ""),
                cp_index,
                cp->pool_holder()->name()->as_C_string(),
                klass_name->as_C_string(), name->as_C_string(), signature->as_C_string());
        if (reason != nullptr) {
          ls.print(" %s", reason;
        }
        ls.cr()


A LogStream we use to assemble a log line that contains too many part. This would also allow you to loose the leading spaces in the string constants.

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

> 549: }
> 550: 
> 551: bool ConstantPoolCache::can_archive_resolved_method(ConstantPool* src_cp, ResolvedMethodEntry* method_entry, const char*& reason) {

I would rename `reason` to `error_reason` or similar; otherwise it reads as "reason why we can archive a resolved method". Naming is important especially since we often don't bother commenting the prototype.

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

PR Review: https://git.openjdk.org/jdk/pull/29690#pullrequestreview-3855592652
PR Review Comment: https://git.openjdk.org/jdk/pull/29690#discussion_r2854343203
PR Review Comment: https://git.openjdk.org/jdk/pull/29690#discussion_r2854280349
PR Review Comment: https://git.openjdk.org/jdk/pull/29690#discussion_r2854321076
PR Review Comment: https://git.openjdk.org/jdk/pull/29690#discussion_r2854335480


More information about the hotspot-dev mailing list