Skip to content

Commit dbb448f

Browse files
borkdudestuarthalloway
authored andcommitted
CLJ-2502: Cannot use clojure.stracktrace/print-stack-trace with GraalVM
Issue is solved by adding type hints. Signed-off-by: Stuart Halloway <stu@cognitect.com>
1 parent 989a3b9 commit dbb448f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/clj/clojure/stacktrace.clj

+6-4
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,20 @@
1515
:author "Stuart Sierra"}
1616
clojure.stacktrace)
1717

18+
(set! *warn-on-reflection* true)
19+
1820
(defn root-cause
1921
"Returns the last 'cause' Throwable in a chain of Throwables."
2022
{:added "1.1"}
21-
[tr]
23+
[^Throwable tr]
2224
(if-let [cause (.getCause tr)]
2325
(recur cause)
2426
tr))
2527

2628
(defn print-trace-element
2729
"Prints a Clojure-oriented view of one element in a stack trace."
2830
{:added "1.1"}
29-
[e]
31+
[^StackTraceElement e]
3032
(let [class (.getClassName e)
3133
method (.getMethodName e)]
3234
(let [match (re-matches #"^([A-Za-z0-9_.-]+)\$(\w+)__\d+$" (str class))]
@@ -39,7 +41,7 @@
3941
"Prints the class and message of a Throwable. Prints the ex-data map
4042
if present."
4143
{:added "1.1"}
42-
[tr]
44+
[^Throwable tr]
4345
(printf "%s: %s" (.getName (class tr)) (.getMessage tr))
4446
(when-let [info (ex-data tr)]
4547
(newline)
@@ -71,7 +73,7 @@
7173
"Like print-stack-trace but prints chained exceptions (causes)."
7274
{:added "1.1"}
7375
([tr] (print-cause-trace tr nil))
74-
([tr n]
76+
([^Throwable tr n]
7577
(print-stack-trace tr n)
7678
(when-let [cause (.getCause tr)]
7779
(print "Caused by: " )

0 commit comments

Comments
 (0)