RFR: 8339113: AccessFlags can be u2 in metadata [v11]

Coleen Phillimore coleenp at openjdk.org
Mon Jan 6 14:12:56 UTC 2025


On Mon, 6 Jan 2025 13:44:27 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:

>> src/hotspot/share/ci/ciFlags.cpp line 95:
>> 
>>> 93: // ciFlags::print
>>> 94: void ciFlags::print(outputStream* st) {
>>> 95:   st->print(" flags=%x", _flags.as_unsigned_short());
>> 
>> Here, and elsewhere, are we relying on an implicit widening of the u2 result to int so that the format specifier is correct?
>
> Yes, we are.

I had a little experiment.

extern "C" int printf(const char *,...);
int main() {
  unsigned short ss = 0x8000;
  printf("does unsigned sign extend to int? %d\n", int(ss));
}

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

PR Review Comment: https://git.openjdk.org/jdk/pull/22246#discussion_r1904172191


More information about the serviceability-dev mailing list