Uploaded image for project: 'CCC Migration Project'
  1. CCC Migration Project
  2. CCC-6479237

(cl) Add support for classloader names

XMLWordPrintable

    • minimal
    • Hide
      The stack trace format is implementation-specific.  The updated stack trace
      format may impact any existing code depending on the old format which is
      not a supported interface.
      Show
      The stack trace format is implementation-specific.  The updated stack trace format may impact any existing code depending on the old format which is not a supported interface.
    • Java API, Other
    • SE

      Summary

      Add support for classloader names

      Problem

      Enhance class loaders to have optional names that can be included in an exception message and stack traces to provide better diagnostics.

      In addition, external module systems can provide better diagnostics.

      Solution

      Add new constructors in ClassLoader, SecureClassLoader and URLClassLoader to specify the class loader name and a new ClassLoader::getName method to return its name.

      Update StackTraceElement to include the class loader name and the stack trace format to include the name of the relevant class loader and module:

          <loader>/<module>/<fully-qualified-name>(<src>:<line>)

      Specification

      Below is a summary of spec change.  Please see the specification from the attached specdiff.

      New constructors are added to java.lang.ClassLoader, java.net.URLClassLoader, and java.security.SecureClassLoader to specify the name of a class loader.

      Add ClassLoader::getName and StackTraceElement::getClassLoaderName methods to return the name of the class loader.

      The name of the builtin platform class loader and application class loader are implementation-specific. Their names are "platform" and "app" respectively as specified in @implNote in ClassLoader::getPlatformClassLoader and ClassLoader::getSystemClassLoader methods.  The names are not printed in stack trace.

      Update the following StackTraceElement constructor that was added in JDK 9 to include a classLoaderName parameter (as the first parameter)

      public StackTraceElement(String moduleName,
                               String moduleVersion,
                               String declaringClass,
                               String methodName,
                               String fileName,
                               int lineNumber)

      The string returned by StackTraceElement::toString() is implementation specific.  The examples showed in the javadoc are updated to reflect the new stack trace format.

        1. ClassLoader-report.html
          129 kB
          Tony Squier
        2. SecureClassLoader-report.html
          18 kB
          Tony Squier
        3. StackTraceElement-report.html
          73 kB
          Tony Squier
        4. URLClassLoader-report.html
          48 kB
          Tony Squier

            mchung Mandy Chung (Inactive)
            mchung Mandy Chung (Inactive)
            Alan Bateman, Daniel Fuchs
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: