-
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
Stacktrace should use the classloader name instead of "app//" #11452
Comments
@sharon-wang can you please take a look at this |
Sure! |
Running with the example program provided in #4998 (comment),
I am seeing similar behaviour between openj9 and the RI: OpenJ9
RI
The caveat relevant to this issue is:
Based on this, it would seem to me that the correct format would be:
instead of the currently seen format by both OpenJ9 and the RI:
Adding OpenJ9
RI
I think OpenJ9 has the correct output here. We now have a named module, so |
@Thihup In your program, does the class fit the description of being loaded by the |
From what I can tell from using both Hotspot and OpenJ9 the following happens:
|
The trick is in the comment of the Javadoc: Via JConsole IIRC in Hotspot they show all the information, but in normal usage, they only show the module name without version for JDK classes.
|
I'll try come up with an example of the named classloader |
Here you go: import java.net.URLClassLoader;
import java.net.URL;
public class NamedClassLoaderTest {
public static void main(String[] args) throws Exception {
var cl = new URLClassLoader("cl.name", new URL[]{new URL("file:///jakarta-servlet-api.jar")}, null);
var servletRequestWrapper = cl.loadClass("jakarta.servlet.http.Cookie");
servletRequestWrapper.getDeclaredConstructor(String.class, String.class).newInstance
(new Object[]{null, null});
}
} You will need this jar: jakarta-servlet-api.zip Stacktrace from Hotspot:
Stacktrace from OpenJ9:
|
If you try to print the classloader name, you will see it is app: System.out.println(NamedClassLoaderTest.class.getClassLoader().getName()); // => app But they don't show it in the stacktrace, maybe only in JConsole. Hope I've gathered enough information. |
Thanks @Thihup, this is great! I see the issue is that we don't provide the classloader name at all. The only time we "happen" to provide it, is via the hardcoded We'll need some changes to
We already have some conditional handling for including the module version which goes in line with
We currently don't have info about the classloader other than its name in |
Disregarding the suggestion in the title, FYI #11447 seems related to this. |
Opened #11601 to include the classloader in the stack trace. With these changes, OpenJ9 now gives the following output for the example program in #11452 (comment):
RI Output:
|
Currently generating the Stacktrace with the extended flag enabled, I guess it should show the classloader name.
However, there's a fixed string "app//"[1]. Probably this was used to get parity with the RI but is not according to the examples of the Javadoc [2].
[1] https://github.com/eclipse/openj9/blob/master/jcl/src/java.base/share/classes/com/ibm/oti/util/Util.java#L304
[2] https://docs.oracle.com/en/java/javase/15/docs/api/java.base/java/lang/StackTraceElement.html#toString()
The text was updated successfully, but these errors were encountered: