On Mon, Oct 14, 2019 at 10:48 PM Joe Darcy <joe.da...@oracle.com> wrote:

> Hi Martin,
> On 10/14/2019 10:28 PM, Martin Buchholz wrote:
>
> Hi Joe,
>
> I'm surprised there were so few changes.
>
>
> The changes in question allow the java.util.concurrent package to pass
> cleanly through the current version of my checks. Perhaps a strong version
> of the checks in the future will flag more issues of possible concern ;-)
>
>
>
> Why are some of the Condition's marked // Conditionally serializable
>
> Summarizing the discussion leading up to the changes for JDK-8231913, 
> "Conditionally
> serializable" describes collections that are serializable iff their
> contents are serializable. The changes made for
>
> 8231202: Suppress warnings on non-serializable non-transient instance
> fields in serializable classes
> http://hg.openjdk.java.net/jdk/jdk/rev/e036ee8bae56
>
> use this terminology in the comments added for many collection types,
> including Vector, TreeMap, and multiple implementation classes in
> java.util.Collections. I tried to follow the same pattern in
> java.util.concurrent where appropriate.
>
The Condition field in ArrayBlockingQueue plays exactly the same role as in
e.g. LinkedBlockingQueue, so should have exactly the same treatment.
---
All Condition implementations in OpenJDK are Serializable.
In fact, we could promote all of those private Condition fields to
ConditionObject, making their Serializability clear, and then elide the
need for suppression.

private final ConditionObject notEmpty = (ConditionObject)
takeLock.newCondition();

(Why won't Java let me declare those fields private final Condition &
Serializable ?)

but now we're drifting into actual user-meaningful development...  We
promise that ReentrantLock is serializable, but we don't seem to have any
such promise for Conditions returned from ReentrantLock.newCondition(), and
we probably should.  Users are implicitly relying on the Serializability of
Condition in the same way we are.

---

Joe, go ahead and commit this to openjdk head when review is done.  We'll
incorporate.

Reply via email to