On Wed, Jul 29, 2009 at 6:09 PM, Jason Wolfe <[email protected]> wrote:
> > Is this a bug? > > user> (eval `(make-array ~Byte/TYPE 2)) > ; Evaluation aborted. (ExceptionInInitializerError) > > Compare: > > user> (eval `(make-array ~Byte 2)) > #<Byte[] [Ljava.lang.Byte;@26fcfd5c> > > user> (eval `(make-array Byte/TYPE 2)) > #<byte[] [...@1f0feb6e> > > user> (make-array (eval Byte/TYPE) 2) > #<byte[] [...@7ce49289> > > If not, can someone please help me understand what's going on here? It's some sort of classloader error: Caused by: java.lang.ClassNotFoundException: byte at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at clojure.lang.DynamicClassLoader.findClass(DynamicClassLoader.java:55) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at java.lang.ClassLoader.loadClass(ClassLoader.java:252) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:169) If you eval `(make-array Byte/TYPE 2) that's two Symbols and an Integer in the s-expr it evaluates. user=> (map type `(make-array Byte/TYPE 2)) (clojure.lang.Symbol clojure.lang.Symbol java.lang.Integer) This works as it does at the REPL. If you eval `(make-array ~Byte/TYPE 2) the s-expr has a Symbol, a literal Class object, and an Integer: user=> (map type `(make-array ~Byte/TYPE 2)) (clojure.lang.Symbol java.lang.Class java.lang.Integer) Apparently eval doesn't like it if a Class object is in an s-expr and is a primitive type's Class, but does not mind if it is a reference type's Class (as when it's just ~Byte in there). It must be that different class-loading is done by eval when it sees a literal Class object than when it sees a Symbol that references a Class. The latter case apparently correctly handles the corner-case that it's a primitive type's Class object, such as Byte/TYPE, while the former case screws up in the same corner-case. I'd consider this to be a bug, or at least a wart. Clojure actually has relatively few of them, far fewer than Java itself or C++, but I'm not too surprised to see the occasional one in such a large and complex software system. Rich will have to make the final decision as to whether this is officially a bug, is expected (though somewhat broken-seeming) behavior, or what, and whether to fix it or not. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---
