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
Wed Oct 16 22:56:49 UTC 2019


Hi Martin,

On 10/16/2019 2:56 PM, Martin Buchholz wrote:
> I did another pass.
>
> If there was a way for jsr166 maintainers to see these warnings, we 
> could more easily fix ourselves.  But there is no such thing as a 
> "preview javac warning", eh?

I could send you the annotation processor I'm using as a prototype, but 
the code isn't publicly visible anywhere as of yet.

(Given my background, it is easier for me to write an annotation 
processor as opposed to writing against the javac internal APIs, but the 
final lint check should use the internal APIs.)

> ---
> 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.


> So just make all of these:
> @SuppressWarnings("serial") // Not statically typed as Serializable

I'll push with the amendments below.

Thanks,

-Joe


>
> ---
> All of the suppressions in ForkJoinTask below should be
> // Conditionally serializable
> because serializability depends on user-supplied action, and T could 
> be any type.
// Remainder elided...


More information about the core-libs-dev mailing list