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

RI does not follow the JVMTI RedefineClasses spec that is too strict in the definition

    XMLWordPrintable

    Details

    • Type: CSR
    • Status: Provisional
    • Priority: P2
    • Resolution: Unresolved
    • Fix Version/s: 13
    • Component/s: hotspot
    • Labels:
      None
    • Subcomponent:
    • Compatibility Kind:
      behavioral
    • Compatibility Risk:
      minimal
    • Compatibility Risk Description:
      Compatibility risk is minimal because the suggested JVM TI spec update is to align the spec with current implementation behavior that has existed from the JDK 1.6 release.
    • Interface Kind:
      Other

      Description

      Summary

      The JVM TI spec for class retransformation and class redefinition does not match the reference implementation which allows adding/deleting private methods to support profiling native methods with Native Method Bind (SetNativeMethodPrefix).

      Problem

      There is a discrepancy between the behavior of Java 11 and JVM TI: https://docs.oracle.com/javase/10/docs/specs/jvmti.html#RetransformClasses https://docs.oracle.com/javase/10/docs/specs/jvmti.html#RedefineClasses

      The JVM TI RetransformClasses spec states: "The retransformation may change method bodies, the constant pool and attributes. The retransformation must not add, remove or rename fields or methods, change the signatures of methods, change modifiers, or change inheritance."

      The JVM TI RedefineClasses spec states: "The redefinition may change method bodies, the constant pool and attributes. The redefinition must not add, remove or rename fields or methods, change the signatures of methods, change modifiers, or change inheritance."

      However, RI allows private methods to be added without throwing JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_ADDED.

      Solution

      The JVM TI spec has to be aligned with the implementation. Aligning the implementation with the JVM TI spec is not a good alternative because current behavior is necessary to support profiling native methods with Native Method Bind (SetNativeMethodPrefix) and a couple of other cases.

      Specification

      Below is the suggested source level update/patch for the JVM TI spec:

      diff -r a8d239bdaaee src/hotspot/share/prims/jvmti.xml
      --- a/src/hotspot/share/prims/jvmti.xml Wed Oct 24 18:14:28 2018 -0700
      +++ b/src/hotspot/share/prims/jvmti.xml Wed Oct 24 21:58:37 2018 -0700
      @@ -7639,8 +7639,8 @@
               
               The retransformation may change method bodies, the constant pool and attributes
               (unless explicitly prohibited).
      -        The retransformation must not add, remove or rename fields or methods, change the
      -        signatures of methods, change modifiers, or change inheritance.
      +        The retransformation must not add, remove or rename fields and non-private methods,
      +        change the signatures of methods, change modifiers, or change inheritance.
               The retransformation must not change the NestHost or
               NestMembers attributes.
               These restrictions may be lifted in future versions.
      @@ -7792,8 +7792,8 @@
               
               The redefinition may change method bodies, the constant pool and attributes
               (unless explicitly prohibited).
      -        The redefinition must not add, remove or rename fields or methods, change the
      -        signatures of methods, change modifiers, or change inheritance.
      +        The redefinition must not add, remove or rename fields and non-private methods,
      +        change the signatures of methods, change modifiers, or change inheritance.
               The retransformation must not change the NestHost or
               NestMembers attributes.
               These restrictions may be lifted in future versions.
      

      Also, please, find the jvmti.diff.html file (specdiff) in the attachments.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                sspitsyn Serguei Spitsyn
                Reporter:
                lkuskov Leonid Kuskov
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated: