Branch: refs/heads/main
  Home:   https://github.com/pmd/pmd
  Commit: 5d65ca49039f19e1beecfc06bb8eb9b8d18f1c6d
      https://github.com/pmd/pmd/commit/5d65ca49039f19e1beecfc06bb8eb9b8d18f1c6d
  Author: fudian <[email protected]>
  Date:   2026-08-18 (Tue, 18 Aug 2026)

  Changed paths:
    M docs/pages/release_notes.md
    M pmd-java/pmd-java-exclude-pmd.properties
    M 
pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/NonSerializableClassRule.java
    A 
pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/ReturnEmptyCollectionRatherThanNullRule.java
    M pmd-java/src/main/resources/category/java/errorprone.xml
    M 
pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/ReturnEmptyCollectionRatherThanNull.xml

  Log Message:
  -----------
  [java] Fix #6744: Analyze possible null return values (#6941)

* [java] Fix #6744: Analyze possible null return values

Replace the XPath rule with a Java rule that analyzes the value reaching
each return statement. Reports an explicit null source (null literal,
conditional value branch, cast, switch yield, plain assignment) for an
array, Collection, or Map return, and for a bare returned local variable
follows its reaching definitions to an explicit null source (#3880, #6695).
Reaching definitions are only followed for a directly returned local, not
for a variable inside a conditional or switch branch, so a null guard such
as x != null ? x : other is not reinterpreted.

The extended analysis now flags a null return in PMD's own source:
NonSerializableClassRule#determinePersistentFields uses null as a "no
serialPersistentFields declaration" sentinel. That is a false positive of
the rule, so the method is annotated @Nullable and suppressed with
@SuppressWarnings. The pmd-main check analyzes with the released PMD,
for which that suppression is unnecessary, so UnnecessaryWarningSuppression
is excluded for the class until 7.27.0 is released.

Signed-off-by: 付典 <[email protected]>

* some minor fixes

---------

Signed-off-by: 付典 <[email protected]>
Co-authored-by: Sören Glimm <[email protected]>



To unsubscribe from these emails, change your notification settings at 
https://github.com/pmd/pmd/settings/notifications


_______________________________________________
Pmd-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pmd-commits

Reply via email to