Note that there are some explanatory texts on larger screens.

plurals
  1. POClojure 1.2.1/1.3/1.4 'proxy generated in Grails 2.0.0 runtime fails. 1.2.0 is fine
    primarykey
    data
    text
    <p>I'm working on extending the <a href="http://grails.org/plugin/clojure" rel="nofollow noreferrer">Grails Clojure plugin</a> in <a href="http://grails.org/doc/2.0.x/guide/introduction.html" rel="nofollow noreferrer">Grails 2.0.0</a> (and 2.1.0-SNAPSHOT) and I wanted to update it to <a href="http://clojure.org/downloads" rel="nofollow noreferrer">Clojure 1.3.0</a> and add <a href="https://github.com/clojure/tools.logging" rel="nofollow noreferrer">clojure.tools.logging</a>. </p> <p>Clojure throws an exception during compilation of a <em>proxy</em> of a <code>ByteArrayOutputStream</code> in <code>clojure.tools.logging</code>'s log-stream function: </p> <p><code>ClassCastException: clojure.asm.Type cannot be cast to clojure.lang.IFn</code></p> <p>( <a href="https://gist.github.com/a6ae681c37091a3d2379" rel="nofollow noreferrer">https://gist.github.com/a6ae681c37091a3d2379</a> )</p> <p>I went and removed <code>clojure.tools.logging</code> and wrote a stripped down <em>proxy</em> of <code>Object</code>: </p> <p><code>(proxy [java.lang.Object] [] (toString [] "proxy's toString"))</code> </p> <p>and it also threw that same <code>ClassCastException</code> and message. </p> <p>I tried to print a <em>macroexpand-1</em> of the <em>proxy</em> and got the same thing. </p> <p>I reverted to Clojure 1.2.0 and <em>proxy</em> worked fine again. </p> <p>I tried a number of incarnations of 1.4.0 and they exhibit the same behavior as 1.3.0. 1.2.1 also throws some sort of exception but I'm trying to hit 1.3.0 so I didn't spend much time with that.</p> <p>The stack trace points to the 'gen-method function defined in one of the <em>let</em> forms of <code>generate-proxy</code> in <code>core_proxy.clj</code>. </p> <p>I added a small smattering of <code>println</code>'s around there to see if I could catch what was happening. Maybe this next statement will betray a huge misunderstanding of the reader on my part but simply adding those <code>println</code>s changed the compile time behavior in a way I totally didn't expect. The exception location and exception type completely changed, even though all the Clojure tests in <code>mvn package</code> continue to pass.</p> <p>For instance, just adding a single <code>println</code> to gen-method right before it starts generating bytecode caused Clojure to throw </p> <p><code>ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to java.lang.Class</code> </p> <p>( <a href="https://gist.github.com/5a7a40929a6c4a104bd5" rel="nofollow noreferrer">https://gist.github.com/5a7a40929a6c4a104bd5</a> )</p> <p>I've seen various other errors depending on where I put the <code>println</code>(s) but this is the most prevalent.</p> <p>Obviously some aspect of Grails and Clojure are not meshing correctly here, but I am not seeing the connection. At first I suspected ASM incompatibility but since Clojure has its own ASM namespace, I can't see that being the issue. But maybe I'm wrong, I've been staring at <code>clojure.lang.Compiler</code>, <em>proxy</em> and <em>generate-proxy</em> for days now trying to get this to work and I've pretty much stopped making forward progress because I've run out of steam :(</p> <p>I apologize for the lack of links. You can copy and paste from below:</p> <p>Grails Clojure - <a href="http://github.com/grails-plugins/grails-clojure" rel="nofollow noreferrer">github.com/grails-plugins/grails-clojure</a></p> <p>Clojure Tools Logging - <a href="http://github.com/clojure/tools.logging/blob/master/src/main/clojure/clojure/tools/logging.clj" rel="nofollow noreferrer">github.com/clojure/tools.logging/blob/master/src/main/clojure/clojure/tools/logging.clj</a> line 133 is the 'proxy </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload