<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Clojure Q&amp;A - Recent questions tagged runtime</title>
<link>https://ask.clojure.org/index.php/tag/runtime</link>
<description></description>
<item>
<title>`(:k m)` returns `nil` while `(identical? (first (keys m)) :k)` is `true` — two coexisting `Keyword` instances?</title>
<link>https://ask.clojure.org/index.php/15073/returns-while-identical-first-coexisting-keyword-instances</link>
<description>&lt;p&gt;We're seeing what looks like a violation of the keyword-interning invariant in production. The bug is deterministic (repeats thousands of times in the same order on the same Aleph/Netty thread) and is cleared by recompiling the affected namespaces via nREPL.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(when (and (map? result) (nil? (:payload result)))   ; this WHEN fires
  (let [payload-key (-&amp;gt;&amp;gt; (keys result)
                         (filter #(.contains (pr-str %) &quot;payload&quot;))
                         first)
        payload-via-key (when payload-key (get result payload-key))]
    (log/warn {:result-type                   (str (type result))
               :result-keys                   (pr-str (keys result))
               :payload-key-equals-literal?   (= payload-key :payload)
               :payload-key-identical?        (identical? payload-key :payload)
               :payload-via-found-key-nil?    (nil? payload-via-key)}
              &quot;diagnostic&quot;)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Logged values when the bug fires:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;{:result-type                   clojure.lang.PersistentArrayMap
 :result-keys                   (:payload :aws-xray)
 :payload-key-equals-literal?   true
 :payload-key-identical?        true
 :payload-via-found-key-nil?    false}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;(:payload result)&lt;/code&gt; in the &lt;code&gt;when&lt;/code&gt; returned nil.&lt;/li&gt;
&lt;li&gt;A few lines later, the diagnostic body proves that the first key in &lt;code&gt;(keys result)&lt;/code&gt; IS the body-site &lt;code&gt;:payload&lt;/code&gt; literal by identity (and therefore by &lt;code&gt;=&lt;/code&gt;, since &lt;code&gt;Keyword&lt;/code&gt; inherits &lt;code&gt;Object.equals&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;(get result that-key)&lt;/code&gt; returns the actual non-nil payload value.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;code&gt;PersistentArrayMap.indexOf&lt;/code&gt; uses &lt;code&gt;==&lt;/code&gt; for &lt;code&gt;Keyword&lt;/code&gt; keys, so the only way &lt;code&gt;(:payload result)&lt;/code&gt; returns nil while &lt;code&gt;(keys result)&lt;/code&gt; yields a key that is &lt;code&gt;identical?&lt;/code&gt; to &lt;code&gt;:payload&lt;/code&gt; at a nearby site is if &lt;strong&gt;the &lt;code&gt;:payload&lt;/code&gt; literal at the WHEN site and the &lt;code&gt;:payload&lt;/code&gt; literal at the body site are two different &lt;code&gt;Keyword&lt;/code&gt; instances&lt;/strong&gt;, even though they're written identically in one source-level function.&lt;/p&gt;
&lt;p&gt;We compareed the &lt;code&gt;:payload&lt;/code&gt; literal with the &lt;code&gt;payload-key&lt;/code&gt; and found that both have - &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;identical content hashcode (&lt;code&gt;-383036092&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;identical name bytes &lt;code&gt;[0x70 0x61 0x79 0x6C 0x6F 0x61 0x64]&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;identical codepoints&lt;/li&gt;
&lt;li&gt;same classloader&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;so it really looks like two distinct interned &lt;code&gt;Keyword&lt;/code&gt; instances with the same name.&lt;/p&gt;
&lt;h4&gt;Environment&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Clojure &lt;code&gt;1.12.4&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Eclipse Temurin JDK 25, Shenandoah GC, virtual threads enabled&lt;/li&gt;
&lt;li&gt;ARM64 (AWS Graviton, ECS Fargate)&lt;/li&gt;
&lt;li&gt;Aleph + Netty, transit-clj/transit-java for decoding&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Questions&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;Could this be a bug in JVM / Clojure runtime?&lt;/li&gt;
&lt;li&gt;Has similar behavior been seen in other cases?&lt;/li&gt;
&lt;li&gt;What more evidence could we capture?&lt;/li&gt;
&lt;/ol&gt;
</description>
<category>Clojure</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/15073/returns-while-identical-first-coexisting-keyword-instances</guid>
<pubDate>Mon, 11 May 2026 12:59:06 +0000</pubDate>
</item>
<item>
<title>Add function that returns every interned keyword in the runtime</title>
<link>https://ask.clojure.org/index.php/12171/add-function-that-returns-every-interned-keyword-the-runtime</link>
<description>&lt;p&gt;Having access to a list of every interned keyword in the runtime is useful for implementing editor auto-completion and other editor integration features.&lt;/p&gt;
&lt;p&gt;Currently, most tooling does something like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user=&amp;gt; (let [field (.getDeclaredField clojure.lang.Keyword &quot;table&quot;)] (.setAccessible field true) (map keyword (.keySet (.get field nil))))
(:target :clojure.main/message :clojure.spec.alpha/unknown :datafy :clojure.core.specs.alpha/prefix :dir :clojure.core.specs.alpha/binding-form :allow ...)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;However, this approach relies on reflection to grab hold of a private, static field. The underlying bits are presumably (albeit unlikely) subject to change without notice.&lt;/p&gt;
&lt;p&gt;Would it be possible to add a function into clojure.core that returns a list of all keywords in the runtime? Perhaps &lt;code&gt;(all-keywords)&lt;/code&gt; (like &lt;code&gt;(all-ns)&lt;/code&gt;). Or perhaps a public static method to &lt;code&gt;clojure.lang.Keyword&lt;/code&gt;?&lt;/p&gt;
&lt;p&gt;See also &lt;a rel=&quot;nofollow&quot; href=&quot;https://grep.app/search?q=.getDeclaredField%20clojure.lang.Keyword%20%22table%22&quot;&gt;grep.app&lt;/a&gt; results for this pattern.&lt;/p&gt;
</description>
<category>REPL</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/12171/add-function-that-returns-every-interned-keyword-the-runtime</guid>
<pubDate>Wed, 07 Sep 2022 18:18:21 +0000</pubDate>
</item>
</channel>
</rss>