On Wed, 9 Sep 2026 20:56:48 GMT, Matias Saavedra Silva <[email protected]> 
wrote:

>> Ioi Lam has updated the pull request incrementally with two additional 
>> commits since the last revision:
>> 
>>  - clean up: ValuePayloadContext::_klass is used only in asserts
>>  - Alternative
>
> src/hotspot/share/runtime/fieldDescriptor.cpp line 314:
> 
>> 312:   if (obj == nullptr) {
>> 313:     assert(vpc == nullptr, "flattening not supported for static 
>> fields");
>> 314:   } else {
> 
> This can be `else if`

The benefit of the current structure is that there's a clear separation between 
the static case and the non-static case. This also matches the layout of 
FieldPrinter::do_field.

 Spit-balling some other suggestions:

  if (obj == nullptr) {
    // Print static fields
    assert(vpc == nullptr, "flattening not supported for static fields");
  } else {
    // Print non-static fields
    if (vpc != nullptr) {
      assert(obj->klass() != vpc->klass(), "a value object cannot be flattened 
into itself");
    }
  }

or (I thought I wrote something like this ...)

  if (obj == nullptr) {
    // Print static fields
    assert(vpc == nullptr, "flattening not supported for static fields");
  } else {
    // Print non-static fields
    assert(vpc == nullptr || obj->klass() != vpc->klass(), "a value object 
cannot be flattened into itself");
  }

or (Probably taking this too far)

    assert(obj != nullptr || vpc == nullptr, "flattening not supported for 
static fields");
    assert(obj == nullptr || vpc == nullptr || obj->klass() != vpc->klass(), "a 
value object cannot be flattened into itself");
  }

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

PR Review Comment: https://git.openjdk.org/jdk/pull/32565#discussion_r3977097795

Reply via email to