JDK 14 RFR of JDK-8232230: Suppress warnings on non-serializable non-transient instance fields in java.util.concurrent
Martin Buchholz
martinrb at google.com
Wed Oct 16 23:39:36 UTC 2019
On Wed, Oct 16, 2019 at 3:56 PM Joe Darcy <joe.darcy at oracle.com> wrote:
>
> > The comments for Condition declarations are still not consistent -
> > every one is known to be Serializable, but they cannot be declared
> > Condition & Serializable because Java does not have first-class
> > support for intersection types.
>
> FWIW, this code compiles in javac
>
> public interface SerializableCondition extends Condition,
> Serializable {
> public static <C extends Condition & Serializable>
> SerializableCondition transform(C
> condition) {
> return condition;
> }
> }
>
> and objects of existing types like
> AbstractQueuedLongSynchronizer.ConditionObject seem to get "converted"
> as desired.
>
Here's another point of view of the same problem:
https://blog.codefx.org/java/intersection-types-var/
More information about the core-libs-dev
mailing list