Skip to content

Commit

Permalink
fix: skip fields analysis for records and enums
Browse files Browse the repository at this point in the history
  • Loading branch information
gtoison committed Apr 21, 2024
1 parent 27d60a2 commit d1a47c4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -8,6 +8,7 @@ Currently the versioning policy of this project follows [Semantic Versioning v2.
## Unreleased - 2024-??-??
### Fixed
- Fix FP `SING_SINGLETON_GETTER_NOT_SYNCHRONIZED` with eager instances ([#2932]https://github.com/spotbugs/spotbugs/issues/2932)
- Fix FP `SE_BAD_FIELD` for record fields ([#2935]https://github.com/spotbugs/spotbugs/issues/2935)

## 4.8.4 - 2024-04-07
### Fixed
Expand Down
Expand Up @@ -22,7 +22,7 @@ void testRecordSerialVersionUid() {
"../java17/ghIssues/Issue2793$SerializableClass.class",
"../java17/ghIssues/Issue2793$YangLibModule.class");

assertBugCount("SE_NO_SERIALVERSIONID", 0);
assertBugCount("SE_NO_SERIALVERSIONID", 2);

assertBugCount("SE_NO_SUITABLE_CONSTRUCTOR_FOR_EXTERNALIZATION", 0);

Expand Down
Expand Up @@ -650,6 +650,10 @@ public void sawOpcode(int seen) {

@Override
public void visit(Field obj) {
if (isEnum || isRecord) {
return;
}

int flags = obj.getAccessFlags();
String genericSignature = obj.getGenericSignature();
if (genericSignature != null && genericSignature.startsWith("T")) {
Expand Down
10 changes: 4 additions & 6 deletions spotbugsTestCases/src/java17/Issue2793.java
Expand Up @@ -7,9 +7,9 @@
import java.io.Serializable;
import java.util.*;

public class Issue2793 implements Serializable {
public static final long serialVersionUID = 1L;

// For issue #2935 we need a serializable class analyzed right before the YangLibModule record
// Due to the ordering of class analysis, we're making this class serializable to reproduce the issue
public class Issue2793 implements Serializable { // SE_NO_SERIALVERSIONID
public record RecordWithoutSerialVersionUid(int x, int y, String message) implements Serializable {

}
Expand All @@ -24,9 +24,7 @@ public void readExternal(ObjectInput in) throws IOException {
}
}

public static class SerializableClass implements Serializable {
public static final long serialVersionUID = 1L;

public static class SerializableClass implements Serializable { // SE_NO_SERIALVERSIONID
public Integer x;
public Integer y;
}
Expand Down

0 comments on commit d1a47c4

Please sign in to comment.