Quoting Jochen Theodorou <
blackdrag@...>:
>> 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.
I would really like a quick fix to this issue: Ehcache will register a
shutdown hook in the Java VM every time the static initializer is
compiled. This means that for every compile, a tiny 5MB memory chunk
is added to PermGen *permanently*. That means that Eclipse will crash
within a minute or so because every key press will run the compiler
once.
I'd also like to take this opportunity to ask for a Groovy
enhancement: The singleton pattern is a widely used one but Java
doesn't exactly support it out of the box. There is a big minefield
around there with synchronization issues, lazy initialization loops,
etc. Would it be possible to add some support in Groovy for this? Like:
@Singleton
SomeClass xxx = { ... code to setup the singleton ... }
or
SomeClass xxx = singleton { ... code to setup the singleton ... }
In both cases, the singleton should be initialized lazily and
thread-safe, and it should not be possible to modify the value of xxx
after the first init.
Regards,
--
Aaron "Optimizer" Digulla a.k.a. Philmann Dark
"It's not the universe that's limited, it's our imagination.
Follow me and I'll show you something beyond the limits."
http://www.pdark.de/---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email