Skip to content

Commit

Permalink
[inspector] Handle InaccessibleObjectException for foreign-module fields
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-yakushev committed Dec 24, 2019
1 parent e64d23d commit 598f621
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/orchard/inspect.clj
Original file line number Diff line number Diff line change
Expand Up @@ -425,11 +425,19 @@
(.getName f))

(field-val [^Field f]
(try (.setAccessible f true)
(catch java.lang.SecurityException e))
(try (.get f obj)
(catch java.lang.IllegalAccessException e
"Access denied.")))
(let [e (try (.setAccessible f true)
nil
(catch Exception e
;; We want to handle specifically SecurityException
;; and j.l.r.InaccessibleObjectException, but the
;; letter only comes with Java9+, so let's just
;; catch everything instead.
e))]
(try (.get f obj)
(catch java.lang.IllegalAccessException _
(symbol
(format "<Access denied%s>"
(when e (str " (" (.getName (.getClass e)) ")"))))))))

(render-fields [inspector section-name fields]
(if (seq fields)
Expand Down

0 comments on commit 598f621

Please sign in to comment.