-
Notifications
You must be signed in to change notification settings - Fork 738
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Include classloader name and module version in stack trace #11601
Conversation
2b83b5e
to
d35735e
Compare
jcl/src/java.base/share/classes/java/lang/StackTraceElement.java
Outdated
Show resolved
Hide resolved
jcl/src/java.base/share/classes/java/lang/StackTraceElement.java
Outdated
Show resolved
Hide resolved
How does the stack trace with module version printed compare with the RI? I think it should also be printed only when |
Re showing |
Yes, in the RI the module version is printed regardless of if |
Sounds good. We can include the classloader name:
Or, I can modify the calculation for |
I've updated the PR title and description to match the changes. Module versions are included by default and classloader names are printed unless the classloader is the Bootstrap or Platform (Extension) classloader. |
This doesn't make sense to me. i.e. normal stack traces don't show module versions for java.base, yet the StackTraceElement contains a module name and version. For example
I happened to run this with Java 16, but same with Java 11, just substitute (for example) "11.0.9".
|
Did some more testing. The behaviour is different between For However, for
the RI shows:
So, for |
Can you take a look at #11523? |
Note StackFrameImpl.toStackTraceElement() in StackWalker.java should set any extra fields added in StackTraceElement. It's going to be used in #11631 |
Took some time to think about the design a bit more. There are two main settings we're concerned about: For
|
cc508e7
to
e58dba4
Compare
798327b
to
0be1ef3
Compare
jcl/src/java.base/share/classes/java/lang/StackTraceElement.java
Outdated
Show resolved
Hide resolved
98b226a
to
be02785
Compare
@pshipton Added/replaced relevant Sidecar19 with |
jenkins compile win jdk8 |
jenkins test sanity.openjdk zlinux jdk11 |
|
Build_JDK11_s390x_linux_Personal, Test_openjdk11_j9_sanity.openjdk_s390x_linux_Personal passed. For the JDK 8 failure, I added a |
Not sure the #if is going to fix Windows. I think you need a cast because on Windows BOOLEAN is UDATA while on other platforms it's U_32. jenkins compile win jdk8,jdk11 |
Still failing on Windows in the jdk11 build.
|
Javadoc notes that if the classloader is named and it is not one of the built-in classloaders: Bootstrap, Platform or System (aka App), then it should be included when printing StackTraceElement. The RI follows the javadoc, but seems to make an exception for the System/App classloader, since it prints `app//` in the stack trace. Currently, we do not specify the classloader name at all. This change matches the RI behaviour in printing the classloader name as appropriate and also matches the RI in printing the module version info for classes loaded by the Application classloader. [skip ci] Signed-off-by: Sharon Wang <sharon-wang-cpsc@outlook.com>
jenkins compile win,osx jdk11 |
I think this is good now. Thanks for all your hard work getting this right @sharon-wang |
Fixes: #11452
Fixes: #11447
Per the javadoc, if the classloader is named and it is not one of the built-in classloaders: Bootstrap, Platform or System (aka App), then it should be included when printing
StackTraceElement
.Javadoc:
The reference implementation appears to show
app/<MODULE>/
in some cases (eg. #11452 (comment)), which is the System/App classloader, a built-in classloader. Although this appears to contradict the javadoc, it seems to only apply when a stack trace is printed by a class other thanThrowable
orStackFrame
, such asThreadInfo
.This PR matches the RI in displaying the classloader name if the element's classloader is the System/App classloader for classes other than
Throwable
orStackFrame
, since it's the expected output of the stack trace for users. So, we will only omit the classloader name if the classloader is one of the Built-in classloaders and the calling class isThrowable
orStackFrame
.Additionally, the RI shows the module version for
StackTraceElement
,Throwable
,StackFrame
andThreadInfo
by default for classes loaded by the App classloader, other than system module classes. ForThreadInfo
orStackTraceElement
s instantiated using a public constructor, the module version is always printed, even for modules such asjava.base
. This PR also matches this behaviour.Note:
StackFrame
output was not fixed in the PR and will be addressed in a future PR. Opened: #11774