Request Review: JDK-6479237 (cl) Add support for classloader names

Mandy Chung mandy.chung at oracle.com
Tue Oct 25 23:10:40 UTC 2016


Webrev at:
   http://cr.openjdk.java.net/~mchung/jdk9/webrevs/6479237/webrev.00/

Specdiff:
   http://cr.openjdk.java.net/~mchung/jdk9/webrevs/6479237/specdiff/overview-summary.html

This is a long-standing RFE for adding support for class
loader names.  It's #ClassLoaderNames on JSR 376 issue 
list where the proposal [1] has been implemented in jake
for some time.  This patch brings this change to jdk9.

A short summary:
- New constructors are added in ClassLoader, SecureClassLoader
  and URLClassLoader to specify the class loader name.

- New ClassLoader::getName and StackTraceElement::getClassLoaderName
  method

- StackTraceElement::toString is updated to include the name
  of the class loader and module of that frame in this format:
     <loader>/<module>/<fully-qualified-name>(<src>:<line>)

The detail is in StackTraceElement::buildLoaderModuleClassName
that compress the output string for cases when the loader
has no name or the module is unnamed module.  Another thing
to mention is that VM sets the Class object when filling in
a stack trace of a Throwable object.  Then the library will
build a String from the Class object for serialization purpose.

Mandy
[1] http://mail.openjdk.java.net/pipermail/jpms-spec-observers/2016-September/000550.html


More information about the hotspot-runtime-dev mailing list