JDK 14 RFR of JDK-8232230: Suppress warnings on non-serializable non-transient instance fields in java.util.concurrent
Joe Darcy
joe.darcy at oracle.com
Thu Oct 17 23:04:52 UTC 2019
Hi Martin,
Hmm. Sorry about that; I thought I was sending something which compiled,
but clearly made a mistake somewhere in the tool chain.
It is possible at some cost to have a SerializableConditionImpl that had
a Serializable field and a Condition field that both pointed to same
object and forwarded methods calls appropriately. However, that adds an
extra layer of objects and indirections.
-Joe
On 10/16/2019 6:11 PM, Martin Buchholz wrote:
>
>
> On Wed, Oct 16, 2019 at 3:56 PM Joe Darcy <joe.darcy at oracle.com
> <mailto:joe.darcy at oracle.com>> wrote:
>
>
> 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.
>
>
> I actually tried this ...
> ---
> import java.io.Serializable;
> import java.util.concurrent.locks.Condition;
>
> public interface SerializableCondition
> extends Condition, Serializable {
> public static <C extends Condition & Serializable>
> SerializableCondition transform(C condition) {
> return condition;
> }
> }
> ---
> ... and got:
>
> ==> javac -source 14 -Xlint:all SerializableCondition.java
> SerializableCondition.java:8: error: incompatible types: C cannot be
> converted to SerializableCondition
> return condition;
> ^
> where C is a type-variable:
> C extends Condition,Serializable declared in method <C>transform(C)
> 1 error
More information about the core-libs-dev
mailing list