On Sun, Nov 24, 2013 at 4:06 PM, Cédric Beust ♔ <[email protected]> wrote:

> Let's be concrete: can you write a program that gets initialized correctly
> with constructor injection and incorrectly with field injection? I've tried
> to come up with one with various techniques (misusing volatile,
> synchronized, the doubly locked idiom, etc...) but I've never been able to
> come up with one. My gut feeling right now is that it can't be done on X86.
>

That's not how the game is played. It's not "Can you come up with an
example that demonstrates a failure for my choice of platform?" It's quite
common to find concurrency bugs that cannot be reliably reproduced.

A better question would be: Is there a program for which the safety
guarantees of final are meaningful? Here's my attempt to construct one:

https://gist.github.com/Tembrel/7633294

It's an artificial program, but data races like these happen in real life.
I'm willing to pay for constructor injection with a little boilerplate to
help defend against the possibility that a library I use is unintentionally
racy.

--tim

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to