At least, there's no bad side effects, we had an issue in 2008
with a Spring context being loaded statically in a class called
at compile time oups :). Took us some time to realize what was going on,
it was exiting (System.exit) if the context could not be loaded.

That's the worse case we hit but it was bad enough.

Could you provide a System property to wrap the static code to detect
if it's compile time or runtime ? That could be a way to avoid
mouse traps... There's a special variable in Clojure set by the compiler
for this purpose but accessing it from java is another story I think.
Passing this to the JVM doing the compilation is by far easier.

Of course it might be quite an amount of work to add this in all the classes
that do static inits but it could be a workaround for the most
problematic cases.

Luc P.


On Wed, 26 Jan 2011 15:36:42 -0800 (PST)
Paul  Mooser <taron...@gmail.com> wrote:

> Luc, I definitely would prefer to avoid odd side effects or complex
> dependencies in static initializers. Unfortunately, I'm integrating
> clojure into an existing system with a large and complex codebase that
> sometimes violates this - it's very similar to the configuration issue
> for log4j that you're mentioning, and while it doesn't seem to have
> any adverse effects, it does result in some alarming warnings being
> emitted (not by the clojure compiler, but by the Java code which is
> detecting that something isn't right when it is loaded).
> 
> On Jan 26, 3:12 pm, Luc Prefontaine <lprefonta...@softaddicts.ca>
> wrote:
> > Accessing external resources from static initializers can be
> > problematic at compile time.
> >
> > For example Log4j usually complains that it cannot find its
> > configuration at compile time. This specific case is a minor issue,
> > it does not have any impacts except the two messages printed on
> > stdout (or stderr).
> >
> > Just make sure you are doing simple things in the class static
> > initializers without any odd side effects.
> >
> > --
> > Luc P.
> >
> > ================
> > The rabid Muppet
> 



-- 
Luc P.

================
The rabid Muppet

-- 
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

Reply via email to