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 authored and bbatsov committed Dec 30, 2019
1 parent aec7d68 commit 78e49b5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## master (unreleased)

* [#81](https://github.com/clojure-emacs/orchard/issues/81): [Inspector] Handle InaccessibleObjectException on Java 9+.
* [#80](https://github.com/clojure-emacs/orchard/issues/80): [Inspector] Render nils in data structures.

## 0.5.4 (2019-11-05)

### Bugs fixed
Expand Down
18 changes: 13 additions & 5 deletions src/orchard/inspect.clj
Original file line number Diff line number Diff line change
Expand Up @@ -428,11 +428,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
;; latter 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 78e49b5

Please sign in to comment.