Skip to content

Commit ac3b61d

Browse files
committed
Fixed NPE in FindReturnRef on inner class fields (spotbugs#3283)
Fixes spotbugs#3283
1 parent e8021d1 commit ac3b61d

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Currently the versioning policy of this project follows [Semantic Versioning v2.
1313
- Fixed the an analysis error when `FindReturnRef` was checking instructions corresponding to a CFG branch that was optimized away ([#3266](https://github.com/spotbugs/spotbugs/issues/3266))
1414
- Added execute file permission to files in the distribution archive ([#3274](https://github.com/spotbugs/spotbugs/issues/3274))
1515
- Fixed a stack overflow in `MultipleInstantiationsOfSingletons` when a singleton initializer makes recursive calls ([#3280](https://github.com/spotbugs/spotbugs/issues/3280))
16+
- Fixed NPE in `FindReturnRef` on inner class fields ([#3283](https://github.com/spotbugs/spotbugs/issues/3283))
1617

1718
## 4.9.0 - 2025-01-15
1819
### Added

spotbugs/src/main/java/edu/umd/cs/findbugs/detect/FindReturnRef.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ public void sawOpcode(int seen) {
315315
}
316316

317317
private boolean isNestedField(XField field) {
318-
if (getThisClass().isNested() && field.getName().startsWith("this$")) {
318+
if (field != null && getThisClass().isNested() && field.getName().startsWith("this$")) {
319319
try {
320320
List<JavaClass> hostClasses = NestedAccessUtil.getHostClasses(getThisClass());
321321
String fieldType = ClassName.fromFieldSignatureToDottedClassName(field.getSignature());

spotbugsTestCases/src/java/exposemutable/FindReturnRefNegativeTest.java

+10
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,16 @@ private void accessParent() {
183183
}
184184
}
185185

186+
public static class PreferenceTreeNode {
187+
private PreferenceTreeNode fParent;
188+
public void addChild(PreferenceTreeNode node) {
189+
node.fParent= this;
190+
}
191+
public PreferenceTreeNode getfParent() {
192+
return fParent;
193+
}
194+
}
195+
186196
private CharBuffer charBuf;
187197
private char[] charArray;
188198

0 commit comments

Comments
 (0)