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

Ioi Lam iklam at openjdk.org
Mon Feb 23 16:52:10 UTC 2026


On Mon, 23 Feb 2026 11:14:23 GMT, María Arias de Reyna Domínguez <duke at openjdk.org> wrote:

>> What I mean is -- in all the places where you add one extra print:
>> 
>> 
>> if (resolved) {
>>   log.print("%s field  CP entry [%3d]: %s => %s.%s:%s%s",
>>             (archived ? "archived" : "reverted"),
>>             cp_index,
>>             cp->pool_holder()->name()->as_C_string(),
>>             klass_name->as_C_string(), name->as_C_string(), signature->as_C_string(),
>>             rfi->is_resolved(Bytecodes::_getstatic) || rfi->is_resolved(Bytecodes::_putstatic) ? " *** static" : "");
>>   if (!archived && !CDSConfig::is_dumping_preimage_static_archive()) {
>>     log.print("%s field  CP entry [%3d] => %s.%s:%s%s can't be archived because its resolution is not deterministic.",
>>               src_cp->pool_holder()->name()->as_C_string(),
>>               cp_index,
>>               klass_name->as_C_string(), name->as_C_string(), signature->as_C_string(),
>>               rfi->is_resolved(Bytecodes::_getstatic) || rfi->is_resolved(Bytecodes::_putstatic) ? " *** static" : "");
>>   }
>> }
>> 
>> 
>> Do this instead so we don't duplicate the code twice and print essentially the same information twice.
>> 
>> The check for `!CDSConfig::is_dumping_preimage_static_archive()` is not necessary for the logs. Try removing it and see if it still works for your scripts.
>> 
>> 
>> if (resolved) {
>>   log.print("%s field  CP entry [%3d]: %s => %s.%s:%s%s%s",
>>             (archived ? "archived" : "reverted"),
>>             cp_index,
>>             cp->pool_holder()->name()->as_C_string(),
>>             klass_name->as_C_string(), name->as_C_string(), signature->as_C_string(),
>>             rfi->is_resolved(Bytecodes::_getstatic) || rfi->is_resolved(Bytecodes::_putstatic) ? " *** static" : "",
>>             (archived ? "" : " (resolution not deterministic)"));
>> }
>
> Now we have three situations:
> 
> `indy`
> 
> [trace  ][aot,resolve] reverted indy   CP entry [ 89]: org/hibernate/sql/results/graph/entity/internal/BatchEntitySelectFetchInitializer (0)    java/lang/invoke/LambdaMetafactory.metafactory:(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite; (resolution is not deterministic)
> 
> 
> `field`
> 
> [trace  ][aot,resolve] reverted field  CP entry [ 17]: org/hibernate/resource/beans/internal/BeansMessageLogger_$logger => org/hibernate/resource/beans/internal/BeansMessageLogger_$logger.FQCN:Ljava/lang/String; (resolution is not deterministic)
> 
> 
> `method`
> 
> [trace][aot,resolve] reverted method CP entry [  2]: org/hibernate/sql/results/graph/entity/internal/EntitySelectFetchInitializerBuilder$BatchMode [Lorg/hibernate/sql/results/graph/entity/internal/EntitySelectFetchInitializerBuilder$BatchMode;.clone:()Ljava/lang/Object; (resolution is not deterministic)
> [trace][aot,resolve] reverted method CP entry [  2]: org/hibernate/sql/results/graph/entity/internal/EntitySelectFetchInitializerBuilder$BatchMode [Lorg/hibernate/sql/results/graph/entity/internal/EntitySelectFetchInitializerBuilder$BatchMode;.clone:()Ljava/lang/Object;
> 
> which is duplicated because one is done on `ConstantPoolCache::can_archive_resolved_method` and the second one at the end of `ConstantPoolCache::remove_resolved_method_entries_if_non_deterministic` which doesn't have the reason (and I don't trust removing the second one just in case we introduce some condition not covered in the previous method).

How about adding an extra parameter to `ConstantPoolCache::can_archive_resolved_method()` to return the reason?


bool ConstantPoolCache::can_archive_resolved_method(ConstantPool* src_cp, ResolvedMethodEntry* method_entry, char** reason) {
  InstanceKlass* pool_holder = constant_pool()->pool_holder();
  if (pool_holder->defined_by_other_loaders()) {
    // Archiving resolved cp entries for classes from non-builtin loaders
    // is not yet supported.
    *reason = "pool holder comes from a non-builtin loader";
    return false;
  }
  ...


Also, the line `LogStreamHandle(Trace, aot, resolve) log;` in this function can be removed.

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

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


More information about the hotspot-dev mailing list