<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Clojure Q&amp;A - Recent questions tagged asm</title>
<link>https://ask.clojure.org/index.php/tag/asm</link>
<description></description>
<item>
<title>Why does Clojure generate too many .class files?</title>
<link>https://ask.clojure.org/index.php/12145/why-does-clojure-generate-too-many-class-files</link>
<description>&lt;p&gt;It turns out Clojure creates a class file per function. As a result, you get too many .class files. &lt;/p&gt;
&lt;p&gt;My question is, why does it generate that many .class files instead of creating a class per namespace and having all functions inside that .class file? &lt;/p&gt;
&lt;p&gt;At least for AOT compilation, that'd be great merging those .class files? I'd like to know the technical reason behind it.&lt;/p&gt;
</description>
<category>Compiler</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/12145/why-does-clojure-generate-too-many-class-files</guid>
<pubDate>Sun, 04 Sep 2022 21:27:27 +0000</pubDate>
</item>
<item>
<title>ArrayIndexOutOfBoundsException in clojure.asm.Frame</title>
<link>https://ask.clojure.org/index.php/11553/arrayindexoutofboundsexception-in-clojure-asm-frame</link>
<description>&lt;p&gt;Hey all :)&lt;/p&gt;
&lt;p&gt;Have hit what I think is a compiler bug this morning, wondering whether it's one I should submit to JIRA?&lt;/p&gt;
&lt;p&gt;Here's what I believe to be a minimal repro:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defprotocol P
  (^double p1 [p a])
  (^double p2 [p a]))

(let [p (reify P)]
  (min 0.0
       (case :p1
         :p1 (p1 p :foo)
         :p2 (p2 p :foo))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Error:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;1. Caused by java.lang.ArrayIndexOutOfBoundsException
   Index -1 out of bounds for length 0

                Frame.java: 1262  clojure.asm.Frame/merge
                Frame.java: 1238  clojure.asm.Frame/merge
         MethodWriter.java: 1604  clojure.asm.MethodWriter/computeAllFrames
         MethodWriter.java: 1540  clojure.asm.MethodWriter/visitMaxs
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;... (have a fuller trace I can send, or the above code snippet should work at a REPL)&lt;/p&gt;
&lt;p&gt;Any of the following make this error go away&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;removing the type hinting  &lt;/li&gt;
&lt;li&gt;adding a nil default to the case &lt;/li&gt;
&lt;li&gt;making the protocol functions normal type-hinted &lt;code&gt;defn&lt;/code&gt;s &lt;/li&gt;
&lt;li&gt;raising the &lt;code&gt;case&lt;/code&gt; out of the &lt;code&gt;min&lt;/code&gt; (removing the &lt;code&gt;min&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I've managed to refactor the original code to work around the issue, but please do let me know if I should raise a JIRA ticket.&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;James&lt;/p&gt;
</description>
<category>Compiler</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/11553/arrayindexoutofboundsexception-in-clojure-asm-frame</guid>
<pubDate>Tue, 08 Feb 2022 13:37:27 +0000</pubDate>
</item>
<item>
<title>Recommended workflow to work on Clojure sources</title>
<link>https://ask.clojure.org/index.php/11191/recommended-workflow-to-work-on-clojure-sources</link>
<description>&lt;p&gt;Hello all,&lt;/p&gt;
&lt;p&gt;Is there a recommended way to work on the Clojure sources, both the java and the clj files?&lt;/p&gt;
&lt;p&gt;For example, I'd like to be able to put a breakpoint in my ide (Intellij Idea) to see how certain parts of the compiler or the core libraries work.&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
</description>
<category>Compiler</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/11191/recommended-workflow-to-work-on-clojure-sources</guid>
<pubDate>Tue, 26 Oct 2021 02:14:01 +0000</pubDate>
</item>
<item>
<title>&quot;file does not contain class clojure.asm.Symbol&quot; warning when clojure-sources is in the classpath</title>
<link>https://ask.clojure.org/index.php/9982/contain-clojure-symbol-warning-clojure-sources-classpath</link>
<description>&lt;p&gt;I have &lt;code&gt;.m2/repository/org/clojure/clojure/1.10.1/clojure-1.10.1-sources.jar&lt;/code&gt; in the classpath, which I do in order to enable (custom) IDE tooling.&lt;/p&gt;
&lt;p&gt;Doing so causes the following warning when launching &lt;code&gt;lein repl&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;/Users/vemv/.m2/repository/org/clojure/clojure/1.10.1/clojure-1.10.1-sources.jar(clojure/asm/SymbolTable.java):49: error: cannot access Symbol
  private static class Entry extends Symbol {
                                     ^
  bad source file: /Users/vemv/.m2/repository/org/clojure/clojure/1.10.1/clojure-1.10.1-sources.jar(clojure/asm/Symbol.java)
    file does not contain class clojure.asm.Symbol
    Please remove or make sure it appears in the correct subdirectory of the sourcepath.
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In contrast, no other &lt;code&gt;&quot;sources&quot;&lt;/code&gt; .jar causes any warning. I can have up to hundreds of such &lt;code&gt;&quot;sources&quot; &lt;/code&gt; jars.&lt;/p&gt;
&lt;p&gt;Perhaps this file has some minor/vestigial issue, such as something related to privacy modifiers, package structure, etc?&lt;/p&gt;
&lt;p&gt;If it was harmless to do, this would seem nice to fix particularly when a single class in a single lib is the only instance of this issue (vs. hundreds of other .jars)&lt;/p&gt;
&lt;p&gt;As a reference, I also found another person encountering the same issue: &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojurians-log.clojureverse.org/clojure/2019-06-23/1561323947.040200&quot;&gt;https://clojurians-log.clojureverse.org/clojure/2019-06-23/1561323947.040200&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;By the way, while this might look as a &lt;code&gt;javac&lt;/code&gt; byproduct, I'm almost positively sure &lt;code&gt;lein repl&lt;/code&gt; is not implicitly invoking &lt;code&gt;javac&lt;/code&gt;. Documentation states so: &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/technomancy/leiningen/blob/0f456829a8b21335aa86390f3ee3d0dcc68410d6/doc/MIXED_PROJECTS.md#java-source-compilation&quot;&gt;https://github.com/technomancy/leiningen/blob/0f456829a8b21335aa86390f3ee3d0dcc68410d6/doc/MIXED_PROJECTS.md#java-source-compilation&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I'm using JDK8.&lt;/p&gt;
</description>
<category>Compiler</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/9982/contain-clojure-symbol-warning-clojure-sources-classpath</guid>
<pubDate>Mon, 28 Dec 2020 16:40:24 +0000</pubDate>
</item>
</channel>
</rss>