Re: JavaMemoryModel: init methods

From: Doug Lea (
Date: Fri Sep 29 2000 - 08:40:40 EDT

> I just want to make two comments about the Bean-style construction.
> > Bean bean = new Bean();
> > bean.setFoo(fooValue);
> > bean.setBar(barValue);
> > return bean;
> 1. Is it really that bad that synchronization is needed for this type of
> construction?

No, it's not bad at all. Except that programmers are known to not do
it in many cases where they ought to. People are known to make lots of
other sync errors too. The only thing that makes this one a little
uncomfortable is that, when the fields foo, bar in above example are
conceptually final-like write-once values, people may wrongly believe
that they don't need synch. But again, I don't think this is a
solvable, or even serious problem for JMM.

> 2. It seems to me that the "problem" with Beans is that we can't
> initialize them in the constructor. What if that weren't the case?

What if pigs could fly? :-)

I don't think there's any way we are going to change the rule that
beans must have no-arg constructors.

JavaMemoryModel mailing list -

This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:00:27 EDT