Re: Keyword equality check

2014-02-13 Thread Arkadiusz Komarzewski
Guys, thank you all for input. I found that both keywords were (as you expected) loaded by same classloader (same parent was used in both). After fixing that the assert indeed fails. Cheers! On Thursday, 13 February 2014 00:41:12 UTC+1, Alex Miller wrote: Reading a little more closely,

Keyword equality check

2014-02-12 Thread Arkadiusz Komarzewski
Hi, I wonder how is equality of keywords implemented in Clojure? I have this piece of Java code executed in one classloader: Keyword a = (Keyword) RT.var(clojure.core, keyword).invoke(keyword); Then, when I pass it to another part of my application (which uses another classloader) and do this:

Re: Keyword equality check

2014-02-12 Thread Jozef Wagner
Interning table uses keyword's symbol as a key, and the symbols are compared by value. See https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Keyword.java#L37 On Wed, Feb 12, 2014 at 5:23 PM, Arkadiusz Komarzewski akomarzew...@gmail.com wrote: Hi, I wonder how is equality

Re: Keyword equality check

2014-02-12 Thread Herwig Hochleitner
I'm willing to bet that both classloaders have the same clojure runtime in a common base classloader. i.e. that cl1.loadClass(clojure.lang.RT) == cl2.loadClass(clojure.lang.RT); If the two clojure runtimes were distinct, the assert would indeed fail. Also .equals return false and this assignment

Re: Keyword equality check

2014-02-12 Thread Alex Miller
I think it's a little more subtle than that. Symbols are composed of a String name and a String namespace. When symbols are created they intern each of those Strings. Interned Strings are comparable by identity across the JVM. Symbol equals() compares name and namespace. Keyword extends from

Re: Keyword equality check

2014-02-12 Thread Alex Miller
Reading a little more closely, that's an identity comparison in Java, not an equals comparison in Clojure (who uses Java anyways? :). So I would retract my last statement. The question is really whether the two classloaders are deferring the load of the common class to a parent classloader