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

Remove leading _ from struct/union declarations in jvmti.h

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 16
    • None
    • hotspot
    • b20

      The generated jvmti.h file uses a leading underscore for struct/union declarations. E.g.,

          struct _jvmtiTimerInfo;
          typedef struct _jvmtiTimerInfo jvmtiTimerInfo;

      It's unclear why this was done (probably to work around really old C compilers that didn't like "typedef struct _jvmtiTimerInfo jvmtiTimerInfo;").

      However, this style breaks encapsulation when making a forward declaration of the jvmtiTimerInfo type in a source file unrelated to jvmti. I.e., one must assume the knowledge of a non-public type "struct _jvmtiTimerInfo".

      We should remove the leading underscore. Hence, we can make forward declarations like this in C++ source code:

          struct jvmtiTimerInfo;

      I.e., "we know that there is a public struct named jvmtiTimerInfo and we don't care what its contents are".

        1. jvmti.h.diff
          6 kB
        2. jvmti.h.new.txt
          80 kB
        3. jvmti.h.old.txt
          80 kB

            iklam Ioi Lam
            iklam Ioi Lam
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: