Details

    • Subcomponent:
    • Compatibility Risk:
      minimal
    • Compatibility Risk Description:
      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.
    • Interface Kind:
      Java API, Other
    • Scope:
      SE

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                mchung Mandy Chung
                Reporter:
                mchung Mandy Chung
                Reviewed By:
                Alan Bateman, Daniel Fuchs
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: