user=> (let [x Integer] (.getName x))
"java.lang.Integer"
user=> (.getName Integer)
java.lang.NoSuchFieldException: getName
I hereby nominate this for the Most Asked question in Clojure. But
just because it gets asked doesn't mean it's easy to search for and
find the answer, so I'm not blaming you at all.
In Java, you can't say Integer.getName(), right? Because the Integer
class doesn't have a static getName() method. Therefore you can't say
(.getName Integer) or (. Integer getName) or (Integer/getName) in
Clojure.
Instead in Java you would have to say Integer.class.getName(), right?
But Clojure gets that class object for you automatically anytime you
try to pass it around, such as when you store it in x in your example.
So that's convenient, but sometimes you need to force it a bit, by
doing something like (.getName (identity Integer))
See also:
http://clojure-log.n01se.net/date/2008-09-06.html#09:26
http://clojure-log.n01se.net/date/2008-08-28.html#21:42
http://groups.google.com/group/clojure/browse_thread/thread/68490633c254dbd1
--Chouser
Understanding the historical reason that (. SomeClass method) doesn't
work, I would be in favor of the deprecation Rich mentioned, leading
to (. SomeClass method) being able to work in the future.
Cheers,
Stuart