Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8293304

Replace some usages of INTPTR_FORMAT with PTR_FORMAT

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Fixed
    • P4
    • 20
    • 20
    • hotspot
    • gc
    • b15

    Description

      During the discussion of JDK-8292981 an opinion was voiced that we should stop using INTPTR_FORMAT when printing pointers.

      Some background that could explain why some tend to use INTPTR_FORMAT instead of PTR_FORMAT:

      Both those format specifiers require an integer and the compiler barfs if you send in a pointer. We therefore have a utility function named p2i, which converts the pointer to an integer. So, everywhere we have to write print line like this: `print("my pointer: " PTR_FORMAT, p2i(my_pointer));`. Now, p2i returns an intptr_t, and it becomes natural for some to consider the type of the converted value (that we need because of the mentioned workaround), instead of the original type of the value.

      With this enhancement I'd like to clean up the code that I often work in, so that it uses PTR_FORMAT when printing pointers. I'm leaving the rest of the code base for others to consider cleaning up.

      Attachments

        Issue Links

          Activity

            People

              stefank Stefan Karlsson
              stefank Stefan Karlsson
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: