RFR(M): 8199852: Print more information about class loaders in LinkageErrors.
lois.foltan at oracle.com
Wed Mar 21 19:26:42 UTC 2018
On 3/21/2018 3:06 PM, Lois Foltan wrote:
> On 3/21/2018 9:03 AM, Lindenmaier, Goetz wrote:
>> Hi Lois,
>> Thanks for looking at this!
>> I had a look at Klass::class_loader_and_module_name(), but there are
>> where you only want to report the class loader information, therefore I
>> decided to do it this way. (If you like this, I have more of these in
>> work :)).
>> For example see expectedErrorMessageDuplicate1 in the test.
>> Also, there might just be a classloader at hand, not a class as needed
>> for that method.
>> But maybe it would make sense to call describe_external() in
>> class_loader_and_module_name() to get more information about
>> the classloader?
> Hi Goetz,
> In the JDK 9 time frame we strove to construct the string representing
> the class loader, module name & module version in a defined,
> structured manner. This allows for consistency across error messages,
> stack dumps, etc. Use of Klass::class_loader_and_name() gives us this
> consistency and you can see some examples of its use in
> ClassCastException messages. See,
> https://bugs.openjdk.java.net/browse/JDK-8165550 and the test,
> test/hotspot/jtreg/runtime/modules/CCE_module_message.java. I strongly
> encourage you to use Klass::class_loader_and_name() and not add
> describe_external(). Klass::class_loader_and_name() could be enhanced
> to take an enum parameter that allows for tailoring of the message
> itself, for example including/not including the module name when
> available, including the parent loader, etc. It could be pulled out
> of Klass for use to obtain a class loader's name when a Klass is not
> available, although Coleen just recently moved it to Klass. I would
> support this type of change.
See the javadoc for java.lang.StackTraceElement,
Specifically the API Note in the StackTraceElement.toString()
description which documents the format and contains examples.
>> Best regards,
>>> -----Original Message-----
>>> From: Lois Foltan [mailto:lois.foltan at oracle.com]
>>> Sent: Mittwoch, 21. März 2018 13:22
>>> To: Lindenmaier, Goetz <goetz.lindenmaier at sap.com>; hotspot-runtime-
>>> dev at openjdk.java.net
>>> Subject: Re: RFR(M): 8199852: Print more information about class
>>> loaders in
>>> On 3/21/2018 7:55 AM, Lindenmaier, Goetz wrote:
>>>> ClassLoaders have a field containing a name since Java 9.
>>>> This change improves some of the messages of LinkageErrors to
>>>> print the name of the loader involved, as well as the parent of the
>>>> This simplifies tracking down the component causing an error in large
>>>> Java systems.
>>>> Please review:
>>>> I ran this through all our tests (jck, jtreg, spec etc). I will
>>>> run it through
>>>> (or jdk/submit) once it's reviewed.
>>>> Best regards,
>>> Hi Goetz,
>>> This looks promising and something that we started to do in the JDK 9
>>> time frame. Instead of adding the new method
>>> java_lang_ClassLoader::describe_external() can you possible use/improve
>>> upon Klass::class_loader_and_module_name() in order to avoid duplicate
More information about the hotspot-runtime-dev