-
CSR
-
Resolution: Approved
-
P3
-
minimal
-
-
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.
- csr for
-
JDK-6479237 (cl) Add support for classloader names
-
- Closed
-