I've also had a lot of problems with def'ed forms. For example, if I do
this:

(def no-spacing (Spacing/createSpacing 0 0 0 false 0))

Which looks like this:

  public static Spacing createSpacing(int minSpaces,
                                      int maxSpaces,
                                      int minLineFeeds,
                                      boolean keepLineBreaks,
                                      int keepBlankLines) {
    return myFactory.createSpacing(minSpaces, maxSpaces, minLineFeeds,
keepLineBreaks, keepBlankLines);
  }

myFactory is injected at some earlier point:

  static void setFactory(SpacingFactory factory) {
    myFactory = factory;
  }

But during compilation that obviously hasn't happened and I get an NPE
during compilation. It's a little annoying that there really seems to be no
good way to create this value at namespace load time if I'm AOT compiling.
I can obviously defer it using defn with memoize or something, but that
seems clunky for what doesn't seem like that crazy a use case.


On 23 October 2013 15:21, Zach Oakes <zsoa...@gmail.com> wrote:

> Here's the error I get when I import LibGDX's Timer class:
>
> http://pastebin.com/q7wys8yi
>
>
> On Tuesday, October 22, 2013 9:55:16 PM UTC-4, Alex Miller wrote:
>>
>> I'd love to see a stack trace when that happens (could even be triggered
>> by dumping stack in your static initializer if nothing else).
>>
>> On Saturday, October 12, 2013 3:17:50 AM UTC-5, Wujek Srujek wrote:
>>>
>>> So you are saying compilation is trying to instantiate class and run
>>> static initializers? This seems very backward, are you sure?
>>>
>>>
>>> On Sat, Oct 12, 2013 at 8:30 AM, Zach Oakes <zso...@gmail.com> wrote:
>>>
>>>> I should add, I am aware I can bring in a class dynamically with
>>>> Class/forName, and that is what I ended up doing for the Timer class.
>>>> However, this is not always practical, and sometimes is simply not an
>>>> option if aot-compilation is required.
>>>>
>>>>
>>>> On Saturday, October 12, 2013 2:28:38 AM UTC-4, Zach Oakes wrote:
>>>>>
>>>>> I recently learned that merely importing a Java class in Clojure
>>>>> causes static initializers to be run. Sometimes, this causes compilation
>>>>> errors, because they are written with the assumption that they will only 
>>>>> be
>>>>> run during runtime.
>>>>>
>>>>> I ran into this just now while trying to make a simple Clojure game
>>>>> with LibGDX. After simply importing its Timer class, I began getting
>>>>> compilation errors. The stack trace shows it is due to a static
>>>>> initializer<https://github.com/libgdx/libgdx/blob/511b557c1a2d23bf8110a05b0ef54cc20b7f958d/gdx/src/com/badlogic/gdx/utils/Timer.java#L32>attempting
>>>>>  to instantiate the class!
>>>>>
>>>>> I also ran into this recently while trying to use RoboVM. My question
>>>>> is, do I have any options? I haven't found many discussions about this 
>>>>> here
>>>>> or elsewhere. This surprises me, because it seems like something more
>>>>> people should be running into.
>>>>>
>>>>  --
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Clojure" group.
>>>> To post to this group, send email to clo...@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+u...@googlegroups.com
>>>> For more options, visit this group at
>>>> http://groups.google.com/**group/clojure?hl=en<http://groups.google.com/group/clojure?hl=en>
>>>> ---
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Clojure" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to clojure+u...@googlegroups.com.
>>>> For more options, visit 
>>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>>>> .
>>>>
>>>
>>>  --
> --
> 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
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to