You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Mark Lundquist <ml...@wrinkledog.com> on 2005/06/06 21:33:06 UTC
[flowscript] help w/ static initialization pb
Hi,
I hope this isn't too lame of a question! :-)
I have a Java class that's referenced from flowscript via
importClass(). The class contains a static initializer block, and this
static initializer block is not getting called.
Any ideas why that would be?
Thanks a lot,
—ml—
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: [flowscript] help w/ static initialization pb
Posted by Jorg Heymans <jh...@domek.be>.
Mark Lundquist wrote:
>
> This class exists only for static things. I just figure out that in
> Java, the static initialization block doesn't run when the class is
> loaded, it gets run upon the first instantiation of the class, and I was
> never instantiating the class.
>
> When I added
>
> new Foo();
>
> to my flowscript, it all started working. I should probably implement a
> real Singleton pattern for this thing.
Static initializer blocks are run only once and that is when the class
is loaded for the first time. I don't know see how flowscript or Rhino
could possibly intercept this as it's a VM thing.
Put a system.out.println() at the top in the static block to verify
this. Maybe you have a silenced exception making you think the block
doesn't get run ?
Regards,
Jorg
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: [flowscript] help w/ static initialization pb
Posted by Mark Lundquist <ml...@wrinkledog.com>.
On Jun 6, 2005, at 12:33 PM, Mark Lundquist wrote:
> Hi,
>
> I hope this isn't too lame of a question! :-)
>
> I have a Java class that's referenced from flowscript via
> importClass(). The class contains a static initializer block, and
> this static initializer block is not getting called.
>
> Any ideas why that would be?
Figured it out. I'm a Java 'tard :-/
This class exists only for static things. I just figure out that in
Java, the static initialization block doesn't run when the class is
loaded, it gets run upon the first instantiation of the class, and I
was never instantiating the class.
When I added
new Foo();
to my flowscript, it all started working. I should probably implement
a real Singleton pattern for this thing.
—ml—
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org