« Return to Thread: Groovy runs code in static initializers during compile

Re: Groovy runs code in static initializers during compile

by Jochen Theodorou :: Rate this Message:

Reply to Author | View in Thread

Aaron Digulla schrieb:
> I'm a big fan of static initializers (aka singletons). In Groovy, I when
> an exception can be thrown in a static initializer, I see this when the
> plugin compiles the code:
> java.lang.ExceptionInInitializerError
>     at java.lang.Class.forName0(Native Method)
>     at java.lang.Class.forName(Class.java:169)
[...]
> org.eclipse.jface.text.reconciler.MonoReconciler.process(MonoReconciler.java:71)
>
>     at
> org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread.run(AbstractReconciler.java:204)
>
> Caused by: java.lang.NullPointerException
>     at
> net.sf.ehcache.CacheManager.replaceCacheWithDecoratedCache(CacheManager.java:838)
>     at ch.globus.basics.cache.GroovyCache.init(GroovyCache.java:44)
[...]
> This tells me that it's unsafe to use singletons in Groovy if they are
> "complex" (for example, when they depend on runtime configuration). Is
> this a bug in the compiler or a general limitation of Groovy?

hmm... I am currently asking myself if we need to resolve the classes we
create when we compile. I know I had once a strange problem with this,
but I think that was with the ReflectorLoader, which is very special
anyway.

hmm... the build seems to be ok with that change...

bye blackdrag

--
Jochen "blackdrag" Theodorou
Groovy Tech Lead (http://groovy.codehaus.org)
http://blackdragsview.blogspot.com/

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

 « Return to Thread: Groovy runs code in static initializers during compile