Skip to content

[java] NonSerializableClass: False negative for generic element/value types of collections and maps #6547

Closed

Description

@zbynek

Affects PMD Version:

7.22.0

Rule: NonSerializableClass

Description:

Non-serializable fields are reported only if their type is not annotated with @Serializable, but not if they are collections/maps involving non-serializable types.

Code Sample demonstrating the issue:

class NotSerializable{};
class SerializeMe implements Serializable {
   private List<NotSerializable> list;
   private Map<Integer, NotSerializable> map1;
   private Map<NotSerializable, Integer> map2;
}

Expected outcome:

PMD should report a violation at lines 3,4,5, but doesn't. This is a false-negative.

Running PMD through: IDE

Activity

  1. added
    a:false-negative
    on Mar 24, 2026
  2. changed the title [-][java] False negative: NotSerializableClass not reporting map and collection types[/-] [+][java] False negative: NonSerializableClass not reporting map and collection types[/+] on Mar 24, 2026
  3. added this to the 7.27.0 milestone on Aug 11, 2026
  4. added a commit that references this issue on Aug 11, 2026
    8a90370
  5. changed the title [-][java] False negative: NonSerializableClass not reporting map and collection types[/-] [+][java] NonSerializableClass: False negative for map and collection types[/+] on Aug 14, 2026
  6. changed the title [-][java] NonSerializableClass: False negative for map and collection types[/-] [+][java] NonSerializableClass: False negative for generic element/value types of collections and maps[/+] on Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:false-negative

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions