[concurrency-interest] private field

David Holmes dholmes@dltech.com.au
Thu, 14 Oct 2004 09:23:49 +1000


> Why fields in classes java.util.concurrent.* like LinkedBlockingQueue
> are declared private instead of protected ?  It's very annoying.

If the fields were protected then we'd be defining a subclassing contract
that we would be forced to honor forever. fields should be internal
implementation details.

So in general you won't find protected fields in library classes. Though in
the absence of a security manager, I believe you can access private fields
reflectively anyway.

What specifically do you want to achieve? There may be an alternative
approach.

David Holmes