Where can I specify a warning-on-reflection in a clj file?

I am trying to use warning-on-reflection in a clj file. When I write:

(set! warn-on-reflection true)

: after ns declaration i get error:

 java.lang.Exception: Unable to resolve symbol: warn-on-reflection in this context 

Does anyone know why?

+5
source share
2 answers

Global variables are conventionally called names that begin and end with an asterisk.

(set! *warn-on-reflection* true)

I think you copied this from a forum that makes such text bold.


Update: add these lines to your leiningen project.clj:

  ;; Emit warnings on all reflection calls.
  :global-vars {*warn-on-reflection* true}

https://github.com/technomancy/leiningen/blob/master/sample.project.clj

+16
source

(set! *warn-on-reflection* true)- This is probably the way to go. If you want to use lein-specific methods for this, here is some updated information for 2.x:

:

(defproject foo ...
  :global-vars {*warn-on-reflection* true}
  ...)

lein check, .

+9

All Articles