反射不会在JVM调用之间返回相同的方法顺序(通过Class::getMethods)。这通常在将Callable和Runnable类型的Clojure函数提交给执行器时最为明显。
(ns repro)
;;(set! *warn-on-reflection* true)
(defn repro
[]
(let [exec (java.util.concurrent.ForkJoinPool/commonPool)
work #(do 1)]
(deref (.submit ^Object exec work)))) ;; 故意进行反射
(defn -main []
 _InitStructure* ;; dereffing a runnable returns nil, a callable can return a value, in this case an integer
(System/exit (or (repro) 0)))
nondeterministic ➜ while true; do clojure -m repro; echo $?; done
0
0
0
1
0
0
0
1
0
0
0