Date: Wed, 24 May 2023 23:07:25 +0000
Subject: [PATCH 48/98] Done!
---
spotbugs/etc/messages.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/spotbugs/etc/messages.xml b/spotbugs/etc/messages.xml
index 824e61aadf4..e7135bd379d 100644
--- a/spotbugs/etc/messages.xml
+++ b/spotbugs/etc/messages.xml
@@ -1778,7 +1778,7 @@ factory pattern to create these objects.
Hiding happens when a sub class defines a static method
with same header (signature plus return type) as any of its super class.
- In case of method hiding , the invoked method is determined based on the specific qualified name or
+ In case of method hiding, the invoked method is determined based on the specific qualified name or
method invocation expression used at the calling site.
The results are often unexpected, although the Java language provides unambiguous rules method invocation for method hiding.
Moreover, method hiding and method overriding is often confused by programmers.
From 1dc124cf26cb74baccd60f2114e9420ba6dff62c Mon Sep 17 00:00:00 2001
From: Nazir Muhammad Zafar Iqbal
Date: Thu, 25 May 2023 01:06:58 +0200
Subject: [PATCH 49/98] Changed the implementation of `isOverriding` to avoid
NPE.
---
.../java/edu/umd/cs/findbugs/detect/FindHidingSubClass.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/spotbugs/src/main/java/edu/umd/cs/findbugs/detect/FindHidingSubClass.java b/spotbugs/src/main/java/edu/umd/cs/findbugs/detect/FindHidingSubClass.java
index 65f2d4d0e3c..2557cdd082e 100644
--- a/spotbugs/src/main/java/edu/umd/cs/findbugs/detect/FindHidingSubClass.java
+++ b/spotbugs/src/main/java/edu/umd/cs/findbugs/detect/FindHidingSubClass.java
@@ -30,6 +30,7 @@
import org.apache.bcel.generic.Type;
import java.util.Arrays;
+import java.util.Objects;
/**
* This detector finds all the methods of a subclass which are hiding the static methods of the superclass and
@@ -154,7 +155,7 @@ private boolean isStringArray(Type[] methodArguments) {
* It then checks the name, signature and 'overridden' being non-final constraints of overriding.
*/
private boolean isOverriding(Method overridden, Method overrider) {
- return overridden.getName().equals(overrider.getName())
+ return Objects.equals(overridden.getName(), overrider.getName())
&& Arrays.equals(overridden.getArgumentTypes(), overrider.getArgumentTypes())
&& !overridden.isFinal();
}
From 380aeabfcb17c314815fd3346600b3ee333a2ffc Mon Sep 17 00:00:00 2001
From: Judit Knoll
Date: Wed, 24 May 2023 23:11:08 +0000
Subject: [PATCH 50/98] Done!
---
.../java/edu/umd/cs/findbugs/detect/FindHidingSubClass.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/spotbugs/src/main/java/edu/umd/cs/findbugs/detect/FindHidingSubClass.java b/spotbugs/src/main/java/edu/umd/cs/findbugs/detect/FindHidingSubClass.java
index 65f2d4d0e3c..eafb6ad4225 100644
--- a/spotbugs/src/main/java/edu/umd/cs/findbugs/detect/FindHidingSubClass.java
+++ b/spotbugs/src/main/java/edu/umd/cs/findbugs/detect/FindHidingSubClass.java
@@ -63,7 +63,7 @@ public void visitClassContext(ClassContext classContext) {
} catch (ClassNotFoundException e) {
AnalysisContext.reportMissingClass(e);
}
- //I store all the methods of both subclass (in separate variables)
+ //I store all the methods of subclass
Method[] methods = subClass.getMethods();
//For each super class, I go through each method of the subclass and filter the non-private and static methods, as private methods can't be overridden.
//I also perform check for main method using auxiliary private method
From f3a1f4892233669065925829e1ae22fe2ca85f29 Mon Sep 17 00:00:00 2001
From: Nazir Muhammad Zafar Iqbal
Date: Thu, 25 May 2023 01:11:57 +0200
Subject: [PATCH 51/98] Suggested the solution to the problem in bug details
message.
---
spotbugs/etc/messages.xml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/spotbugs/etc/messages.xml b/spotbugs/etc/messages.xml
index e7135bd379d..ac06a2a7fad 100644
--- a/spotbugs/etc/messages.xml
+++ b/spotbugs/etc/messages.xml
@@ -1783,6 +1783,7 @@ factory pattern to create these objects.
The results are often unexpected, although the Java language provides unambiguous rules method invocation for method hiding.
Moreover, method hiding and method overriding is often confused by programmers.
Consequently, programmers must avoid the method hiding.
+ Programmer should declare the respective methods non-static or restrict it as private to eradicate the problem.
]]>