I don’t really understand how the bean function works when I am using it on beans. This code here throws an exception:
(import java.lang.management.ManagementFactory) (def runtime (bean (ManagementFactory/getRuntimeMXBean)) (:name runtime) ;; => Class clojure.core$bean$fn__5177$fn__5178 can not access a member of class sun.management.RuntimeImpl with modifiers "public" [Thrown class java.lang.IllegalAccessException]
but the class does have a method called getName(). http://docs.oracle.com/javase/6/docs/api/java/lang/management/RuntimeMXBean.html
You must have missed it, it’s right there.
;; =>
Class clojure.core$bean$fn_5177$fn_5178 can not access a member of class sun.management.RuntimeImpl with modifiers “public”
[Thrown class java.lang.IllegalAccessException]
but the class does have a method called getName(). http://docs.oracle.com/javase/6/docs/api/java/lang/management/RuntimeMXBean.html
ing Java virtual machine.
Edit1:
This issue is very similar to one here and response to it is here.
Class
RuntimeImplreturned byManagementFactory.getRuntimeMXBeanis only package visible but it implements public visible interfaceRuntimeMXBean. So what happens is that functionbeantries to call a method on the classRuntimImplbut it can’t as class is only package visible. I think if it tried to callgetMethodon interfaceRuntimeMXBeanit would have worked.Yeap this works:
I’m not sure if it’s a bug or feature. I would recommend asking on Clojure mailing list.