-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JavaStackTrace: Added support stack frame element class loaders and m…
…odules (#2658)
- Loading branch information
1 parent
0803525
commit 0bb4f09
Showing
3 changed files
with
246 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
// Specification: | ||
// https://docs.oracle.com/en/java/javase/13/docs/api/java.base/java/lang/Throwable.html#printStackTrace() | ||
|
||
Prism.languages.javastacktrace = { | ||
|
||
// java.sql.SQLException: Violation of unique constraint MY_ENTITY_UK_1: duplicate value(s) for column(s) MY_COLUMN in statement [...] | ||
|
@@ -38,12 +41,30 @@ Prism.languages.javastacktrace = { | |
|
||
// at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166) | ||
// at org.hsqldb.jdbc.Util.throwError(Unknown Source) here could be some notes | ||
// at java.base/java.lang.Class.forName0(Native Method) | ||
// at Util.<init>(Unknown Source) | ||
// at com.foo.loader/[email protected]/com.foo.Main.run(Main.java:101) | ||
// at com.foo.loader//com.foo.bar.App.run(App.java:12) | ||
// at [email protected]/org.acme.Lib.test(Lib.java:80) | ||
// at MyClass.mash(MyClass.java:9) | ||
// | ||
// More information: | ||
// https://docs.oracle.com/en/java/javase/13/docs/api/java.base/java/lang/StackTraceElement.html#toString() | ||
// | ||
// A valid Java module name is defined as: | ||
// "A module name consists of one or more Java identifiers (§3.8) separated by "." tokens." | ||
// https://docs.oracle.com/javase/specs/jls/se9/html/jls-6.html#jls-ModuleName | ||
// | ||
// A Java module version is defined by this class: | ||
// https://docs.oracle.com/javase/9/docs/api/java/lang/module/ModuleDescriptor.Version.html | ||
// This is the implementation of the `parse` method in JDK13: | ||
// https://github.com/matcdac/jdk/blob/2305df71d1b7710266ae0956d73927a225132c0f/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java#L1108 | ||
// However, to keep this simple, a version will be matched by the pattern /@[\w$.+-]*/. | ||
'stack-frame': { | ||
pattern: /^[\t ]*at [\w$.]+(?:<init>)?\([^()]*\)/m, | ||
pattern: /^[\t ]*at (?:[\w$./]|@[\w$.+-]*\/)+(?:<init>)?\([^()]*\)/m, | ||
inside: { | ||
'keyword': { | ||
pattern: /^(\s*)at/, | ||
pattern: /^(\s*)at(?= )/, | ||
lookbehind: true | ||
}, | ||
'source': [ | ||
|
@@ -74,8 +95,33 @@ Prism.languages.javastacktrace = { | |
], | ||
'class-name': /[\w$]+(?=\.(?:<init>|[\w$]+)\()/, | ||
'function': /(?:<init>|[\w$]+)(?=\()/, | ||
'namespace': /[a-z]\w*/, | ||
'punctuation': /[.()]/ | ||
'class-loader': { | ||
pattern: /(\s)[a-z]\w*(?:\.[a-z]\w*)*(?=\/[\w@$.]*\/)/, | ||
lookbehind: true, | ||
alias: 'namespace', | ||
inside: { | ||
'punctuation': /\./ | ||
} | ||
}, | ||
'module': { | ||
pattern: /([\s/])[a-z]\w*(?:\.[a-z]\w*)*(?:@[\w$.+-]*)?(?=\/)/, | ||
lookbehind: true, | ||
inside: { | ||
'version': { | ||
pattern: /(@)[\s\S]+/, | ||
lookbehind: true, | ||
alias: 'number' | ||
}, | ||
'punctuation': /[@.]/ | ||
} | ||
}, | ||
'namespace': { | ||
pattern: /(?:[a-z]\w*\.)+/, | ||
inside: { | ||
'punctuation': /\./ | ||
} | ||
}, | ||
'punctuation': /[()/.]/ | ||
} | ||
}, | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,15 @@ at Main.main(Main.java:13) | |
at Main.main(Main.java:13) Same but with some additional notes | ||
at com.foo.bar.Main$FooBar.main(Native Method) | ||
at Main$FooBar.<init>(Unknown Source) | ||
at java.base/java.util.jar.JavaUtilJarAccessImpl.ensureInitialization(JavaUtilJarAccessImpl.java:69) | ||
at java.base/java.lang.Class.forName0(Native Method) | ||
at com.foo.loader/[email protected]/com.foo.Main.run(Main.java:101) | ||
at com.foo.loader//com.foo.bar.App.run(App.java:12) | ||
at [email protected]/org.acme.Lib.test(Lib.java:80) | ||
at MyClass.mash(MyClass.java:9) | ||
|
||
// not to forget our swiss friends | ||
at at.foo.bar.Main$FooBar.main(Native Method) | ||
|
||
---------------------------------------------------- | ||
|
||
|
@@ -37,12 +46,14 @@ at Main$FooBar.<init>(Unknown Source) | |
|
||
["stack-frame", [ | ||
["keyword", "at"], | ||
["namespace", "com"], | ||
["punctuation", "."], | ||
["namespace", "foo"], | ||
["punctuation", "."], | ||
["namespace", "bar"], | ||
["punctuation", "."], | ||
["namespace", [ | ||
"com", | ||
["punctuation", "."], | ||
"foo", | ||
["punctuation", "."], | ||
"bar", | ||
["punctuation", "."] | ||
]], | ||
["class-name", "Main$FooBar"], | ||
["punctuation", "."], | ||
["function", "main"], | ||
|
@@ -63,6 +74,184 @@ at Main$FooBar.<init>(Unknown Source) | |
["keyword", "Unknown Source"] | ||
]], | ||
["punctuation", ")"] | ||
]], | ||
|
||
["stack-frame", [ | ||
["keyword", "at"], | ||
["module", [ | ||
"java", | ||
["punctuation", "."], | ||
"base" | ||
]], | ||
["punctuation", "/"], | ||
["namespace", [ | ||
"java", | ||
["punctuation", "."], | ||
"util", | ||
["punctuation", "."], | ||
"jar", | ||
["punctuation", "."] | ||
]], | ||
["class-name", "JavaUtilJarAccessImpl"], | ||
["punctuation", "."], | ||
["function", "ensureInitialization"], | ||
["punctuation", "("], | ||
["source", [ | ||
["file", "JavaUtilJarAccessImpl.java"], | ||
["punctuation", ":"], | ||
["line-number", "69"] | ||
]], | ||
["punctuation", ")"] | ||
]], | ||
|
||
["stack-frame", [ | ||
["keyword", "at"], | ||
["module", [ | ||
"java", | ||
["punctuation", "."], | ||
"base" | ||
]], | ||
["punctuation", "/"], | ||
["namespace", [ | ||
"java", | ||
["punctuation", "."], | ||
"lang", | ||
["punctuation", "."] | ||
]], | ||
["class-name", "Class"], | ||
["punctuation", "."], | ||
["function", "forName0"], | ||
["punctuation", "("], | ||
["source", [ | ||
["keyword", "Native Method"] | ||
]], | ||
["punctuation", ")"] | ||
]], | ||
|
||
["stack-frame", [ | ||
["keyword", "at"], | ||
["class-loader", [ | ||
"com", | ||
["punctuation", "."], | ||
"foo", | ||
["punctuation", "."], | ||
"loader" | ||
]], | ||
["punctuation", "/"], | ||
["module", [ | ||
"foo", | ||
["punctuation", "@"], | ||
["version", "9.0"] | ||
]], | ||
["punctuation", "/"], | ||
["namespace", [ | ||
"com", | ||
["punctuation", "."], | ||
"foo", | ||
["punctuation", "."] | ||
]], | ||
["class-name", "Main"], | ||
["punctuation", "."], | ||
["function", "run"], | ||
["punctuation", "("], | ||
["source", [ | ||
["file", "Main.java"], | ||
["punctuation", ":"], | ||
["line-number", "101"] | ||
]], | ||
["punctuation", ")"] | ||
]], | ||
|
||
["stack-frame", [ | ||
["keyword", "at"], | ||
["class-loader", [ | ||
"com", | ||
["punctuation", "."], | ||
"foo", | ||
["punctuation", "."], | ||
"loader" | ||
]], | ||
["punctuation", "/"], | ||
["punctuation", "/"], | ||
["namespace", [ | ||
"com", | ||
["punctuation", "."], | ||
"foo", | ||
["punctuation", "."], | ||
"bar", | ||
["punctuation", "."] | ||
]], | ||
["class-name", "App"], | ||
["punctuation", "."], | ||
["function", "run"], | ||
["punctuation", "("], | ||
["source", [ | ||
["file", "App.java"], | ||
["punctuation", ":"], | ||
["line-number", "12"] | ||
]], | ||
["punctuation", ")"] | ||
]], | ||
|
||
["stack-frame", [ | ||
["keyword", "at"], | ||
["module", [ | ||
"acme", | ||
["punctuation", "@"], | ||
["version", "2.1"] | ||
]], | ||
["punctuation", "/"], | ||
["namespace", [ | ||
"org", | ||
["punctuation", "."], | ||
"acme", | ||
["punctuation", "."] | ||
]], | ||
["class-name", "Lib"], | ||
["punctuation", "."], | ||
["function", "test"], | ||
["punctuation", "("], | ||
["source", [ | ||
["file", "Lib.java"], | ||
["punctuation", ":"], | ||
["line-number", "80"] | ||
]], | ||
["punctuation", ")"] | ||
]], | ||
|
||
["stack-frame", [ | ||
["keyword", "at"], | ||
["class-name", "MyClass"], | ||
["punctuation", "."], | ||
["function", "mash"], | ||
["punctuation", "("], | ||
["source", [ | ||
["file", "MyClass.java"], | ||
["punctuation", ":"], | ||
["line-number", "9"] | ||
]], | ||
["punctuation", ")"] | ||
]], | ||
|
||
"\n\n// not to forget our swiss friends\n", | ||
["stack-frame", [ | ||
["keyword", "at"], | ||
["namespace", [ | ||
"at", | ||
["punctuation", "."], | ||
"foo", | ||
["punctuation", "."], | ||
"bar", | ||
["punctuation", "."] | ||
]], | ||
["class-name", "Main$FooBar"], | ||
["punctuation", "."], | ||
["function", "main"], | ||
["punctuation", "("], | ||
["source", [ | ||
["keyword", "Native Method"] | ||
]], | ||
["punctuation", ")"] | ||
]] | ||
] | ||
|
||
|