On Wed, 2 Jul 2025 23:18:38 GMT, Chen Liang <li...@openjdk.org> wrote:

>> src/hotspot/share/classfile/classFileParser.cpp line 5171:
>> 
>>> 5169:       InstanceKlass* intf = _transitive_interfaces->at(i);
>>> 5170:       if (intf->class_initializer() != nullptr) {
>>> 5171:         if (!intf->has_aot_safe_initializer()) {
>> 
>> I think this is better, so you don't need to annotate a supertypes that have 
>> no `<clinit>`
>> 
>> 
>> if (intf->class_initializer() != nullptr && 
>> !intf->has_aot_safe_initializer()) {
>
> Also quick question: Should I use `_transitive_interfaces` or can I use 
> `_local_interfaces`?

local_interfaces is fine, because the interfaces implemented by the super 
classes would have been checked when the super classes were loaded.

BTW, the error message should include the name of both this class and the 
supertype:


classfile_parse_error("AOTSafeClassInitlaizer annotation is required for 
supertype %s of %s", ...


And the checks can be refactored in a separate function to avoid repetition.


if (_super_klass != nullptr) {
  check_aot_safe_initializer(ik, _super_klass, CHECK);
}
int len = _local_interfaces->length();
for (int i = 0; i < len; i++) {
  check_aot_safe_initializer(ik, _local_interfaces->at(i), CHECK);
}

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25922#discussion_r2181197886

Reply via email to