On Jul 3, 5:27 am, jon <superuser...@googlemail.com> wrote:
> Hi, could Rich or someone knowledgeable look into this (reflection
> related?) NullPointerException in Compiler.java.
> I think it's either a bug or at least should provide a better error
> message, but I don't have any time to look deeper into it..
> Thanks, Jon
>
> -----
> I was using clojure-1.0 but looks likely to still be a problem with
> the trunk.
>
> * compile the below java class and make available on classpath:
> package mypkg;
> public class MyClass {
> public MyClass() {
> }
> Object myField;
> }
>
> * then this line of clojure throws a NullPointerException:
> (set! (.myField (mypkg.MyClass.)) "test")
>
> -----
> When myField definition is private, as above, (or completely removed)
> the NullPointerException
> occurs. When you add 'public' to myField definition, the problem goes
> away..
>
> Looking at InstanceFieldExpr in Compiler.java (approx line 900)..
> the emit() and emitUnboxed() functions guard against 'field' being
> null
> if(targetClass != null && field != null)
> but the emitAssign() function doesn't
> if(targetClass != null)
> and therefore in this case field.getType() causes the
> NullPointerException
Fixed - thanks for the report:
http://www.assembla.com/spaces/clojure/tickets/142-Bug--Compile-time-NPE-on-set!-of-non-existent-field
RIch
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---