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

Convert dynamic proxy to hidden classes

    XMLWordPrintable

Details

    • CSR
    • Resolution: Unresolved
    • P4
    • 24
    • core-libs
    • None
    • behavioral
    • medium
    • Hide
      Some programs might have relied on dynamic proxy classes being non-hidden, strongly-linked to ClassLoader, or its appearance in stack traces; but these are not specifed by Proxy.

      Other examples include:
      1. Clients may use getName on Proxy classes and use forName to retrieve those classes; this does not work with hidden classes.
      2. Clients may instrument Proxy classes; instrumentations aren't supported by hidden classes.
      Show
      Some programs might have relied on dynamic proxy classes being non-hidden, strongly-linked to ClassLoader, or its appearance in stack traces; but these are not specifed by Proxy. Other examples include: 1. Clients may use getName on Proxy classes and use forName to retrieve those classes; this does not work with hidden classes. 2. Clients may instrument Proxy classes; instrumentations aren't supported by hidden classes.
    • Java API, System or security property
    • SE

    Description

      Summary

      Reimplement dynamic proxy with hidden classes.

      Problem

      1. Dynamic proxies are implementation artifacts, yet they show up in stacktraces;
      2. Dynamic proxies are defined to ClassLoaders, and their life is bound to the class loader; it would be too costly to create new ClassLoaders to allow easy unloading of Dynamic proxies.
      3. Dynamic proxies cannot easily access the Method objects for the methods it implement, and need extra code to setup.

      Solution

      Change dynamic proxies implementation to be hidden classes, being hidden in stacktraces and flexible in unloading. (Full unloading support needs further cache implementation update.) As hidden classes, they now access the Method objects via classdata, avoiding extra computations and allowing implementation classes to reach the physical classfile limits later.

      Specification

      There is no change to Proxy specification. The new implementation still conforms to those specification, such as serialization, system protection domain, and dynamic module.

      Since there are some observable behavior changes, an undocumented system property -Djdk.reflect.useLegacyProxyImpl=true can be set to use the old implementation. In addition, if -Djdk.reflect.useOldSerializableConstructor=true is set, the implementation will automatically switch to the old one since old serializable constructors are not compatible with hidden classes.

      A release note will be created for this change.

      Attachments

        Issue Links

          Activity

            People

              liach Chen Liang
              mchung Mandy Chung
              Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: