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

Update example for Extension Event in jvmti specs

    XMLWordPrintable

    Details

    • Subcomponent:
    • Compatibility Kind:
      behavioral
    • Compatibility Risk:
      minimal
    • Interface Kind:
      Other
    • Scope:
      JDK

      Description

      Summary

      The JVMTI specification describes the "Extension Event" and gives an example, but the example doesn't match the specification. The example must be changed to match the specification. This is a clear copy of the same CSR for openjdk16.

      Problem

      In the JVMTI specification, in the description of "Extension Event", the specification for the extension event callback function is given as:

      typedef void (JNICALL *jvmtiExtensionEvent)
           (jvmtiEnv* jvmti_env,
            ...);

      But the example for a handler that takes a jint parameter is given as:

      void JNICALL myHandler(jvmtiEnv* jvmti_env, jint myInt, ...)

      Here a variadic function argument (myInt) is declared as a constant argument. On some platforms constant and variadic arguments are passed differently, and following the example will result in error on such platforms.

      Solution

      Change the example function to match the specification of jvmtiExtensionEvent and only take a varargs parameter. Change IsClassUnloadingEnabled function in hotspot to match updated spec.

      Specification

      src/hotspot/share/prims/jvmti.xml
      
                 there is a <code>jint</code> parameter, the event handler should be
                 declared:
       <example>
      -    void JNICALL myHandler(jvmtiEnv* jvmti_env, jint myInt, ...)
      +    void JNICALL myHandler(jvmtiEnv* jvmti_env, ...)
       </example>
                 Note the terminal "<code>...</code>" which indicates varargs.
      +          The <code>jint</code> argument inside <code>myHandler</code> needs to be extracted using
      +          the <code>va_*</code> syntax of the C programming language.
               </description>
               <parameters>
                 <param id="jvmti_env">

      and additionally in jvmtiExtensions.cpp

      -static jvmtiError JNICALL IsClassUnloadingEnabled(const jvmtiEnv* env, jboolean* enabled, ...) {
      +static jvmtiError JNICALL IsClassUnloadingEnabled(const jvmtiEnv* env, ...) {

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              vkempik Vladimir Kempik
              Reporter:
              vkempik Vladimir Kempik
              Reviewed By:
              Joe Darcy
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: