Welcome! Please see the About page for a little more info on how this works.

+1 vote
in Clojure by

Problem
I tried to use {{clojure.stracktrace/print-stack-trace}} with GraalVM but that doesn't work since reflection is needed to find the method {{getMessage}}.

Proposed solution
This can be resolved by adding type hints.

An overview of warnings emitted by
`(set! warn-on-reflection true)`
:

Reflection warning, /tmp/stacktrace.clj:24:18 - reference to field getCause can't be resolved. Reflection warning, /tmp/stacktrace.clj:32:15 - reference to field getClassName can't be resolved. Reflection warning, /tmp/stacktrace.clj:33:9 - reference to field getMethodName can't be resolved. Reflection warning, /tmp/stacktrace.clj:38:26 - reference to field getFileName can't be resolved. Reflection warning, /tmp/stacktrace.clj:38:47 - reference to field getLineNumber can't be resolved. Reflection warning, /tmp/stacktrace.clj:45:42 - reference to field getMessage can't be resolved. Reflection warning, /tmp/stacktrace.clj:24:18 - reference to field getCause can't be resolved.

Patch CLJ-2502-2.patch removes unwanted whitespace changes and moves the type hint of {{root-cause}} higher up.

Screened by: Alex Miller

6 Answers

0 votes
by

Comment made by: borkdude

I'd be happy to implement the fix myself, after some vetting of this issue.

0 votes
by

Comment made by: alexmiller

Go for it! Feel free to put the warn-on-reflect setting in the top of the code in the patch.

0 votes
by

Comment made by: borkdude

Tested this with GraalVM and it now works.

0 votes
by

Comment made by: alexmiller

There seem to be some extraneous indenting changes in there - if you could minimize those, that would be helpful. For root-cause, I'd prefer the type hint as high as possible (in the arg). Can you update those?

0 votes
by

Comment made by: borkdude

Done.

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJ-2502 (reported by borkdude)
...