(ns scratch.fastflip
(:gen-class
:extends java.util.Random
:implements clojure.lang.IFn))
(defn -invoke [^java.util.Random this]
(.next this 1))
Loading the file I get the warning:
;scratch.coin=> Reflection warning, /home/user/scratch/src/scratch/fastflip.clj:8 - call to next can't be resolved.
#'scratch.fastflip/-invoke
Note I want to get rid of the warning via eliminating the reflection, not via setting warning mechanism to false.
If you’re on 1.3, this is probably because
nexttakes an int, not a long, and 1 is an int. But are you surenextis what you want to call? If you’re doing coin-flipping, I would just usenextInt(2), asnextlooks like implementation internals.Edit: Here’s syntax you can use to do what you want without a reflection warning.