On Fri, 3 Apr 2026 01:46:29 GMT, Vicente Romero <[email protected]> wrote:

>> This PR is adding a new serialization warning for the case when a value 
>> class declares one of the following serialization related methods:
>> 
>> - readObject
>> - writeObject
>> - readObjectNoData
>> 
>> They have no effect if declared in value classes, fact that should be 
>> notified to the user,
>> 
>> TIA
>
> Vicente Romero has updated the pull request with a new target base due to a 
> merge or a rebase. The incremental webrev excludes the unrelated changes 
> brought in by the merge/rebase. The pull request contains 10 additional 
> commits since the last revision:
> 
>  - adding more documentation
>  - Merge branch 'lworld' into JDK-8378908
>  - doc change
>  - addressing review comments
>  - Merge branch 'lworld' into JDK-8378908
>  - Merge branch 'lworld' into JDK-8378908
>  - Update src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java
>    
>    Co-authored-by: Chen Liang <[email protected]>
>  - Update src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java
>    
>    Co-authored-by: Chen Liang <[email protected]>
>  - adding tests plus bug fix
>  - 8378908: [lworld] Serializations warnings for value classes that have 
> private serialization methods

Looks all good otherwise.

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java line 5354:

> 5352:             // Excluding abstract, could have a more complicated
> 5353:             // rule based on abstract-ness of the class
> 5354:             return isConcreteInstanceMethod(tree, method, warn) &  // 
> no short-circuit we need to evaluate all

Suggestion:

            return isConcreteInstanceMethod(tree, method, warn) &  // no 
short-circuit we need to log warnings

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java line 5367:

> 5365:             // private void readObject(ObjectInputStream stream)
> 5366:             //   throws IOException, ClassNotFoundException
> 5367:             return isPrivateNonStaticMethod(tree, method) & // no 
> short-circuit we need to evaluate all

Suggestion:

            return isPrivateNonStaticMethod(tree, method) & // no short-circuit 
we need to log warnings

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java line 5376:

> 5374:         private boolean hasAppropriateReadObjectNoData(JCClassDecl 
> tree, Element e, MethodSymbol method) {
> 5375:             // private void readObjectNoData() throws 
> ObjectStreamException
> 5376:             return isPrivateNonStaticMethod(tree, method) &

Suggestion:

            return isPrivateNonStaticMethod(tree, method) & // no short-circuit 
we need to log warnings

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java line 5389:

> 5387:             // Excluding abstract, could have a more complicated
> 5388:             // rule based on abstract-ness of the class
> 5389:             return isConcreteInstanceMethod(tree, method, true) & // no 
> short-circuit we need to evaluate all

Suggestion:

            return isConcreteInstanceMethod(tree, method, true) & // no 
short-circuit we need to log warnings

-------------

PR Review: 
https://git.openjdk.org/valhalla/pull/2187#pullrequestreview-4055615744
PR Review Comment: 
https://git.openjdk.org/valhalla/pull/2187#discussion_r3032774126
PR Review Comment: 
https://git.openjdk.org/valhalla/pull/2187#discussion_r3032774770
PR Review Comment: 
https://git.openjdk.org/valhalla/pull/2187#discussion_r3032775673
PR Review Comment: 
https://git.openjdk.org/valhalla/pull/2187#discussion_r3032776274

Reply via email to