Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New detector for MET07-J #2467

Open
wants to merge 115 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 109 commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
19087fc
Added the messages.xml and findbugs.xml components for my second chec…
NazirMuhammadZafarIqbal Apr 2, 2023
28bf58c
Added test cases calsses.
NazirMuhammadZafarIqbal Apr 2, 2023
4e461cf
Added test class (JUnit) as well.
NazirMuhammadZafarIqbal Apr 2, 2023
b0c19f8
Added Checker as well.
NazirMuhammadZafarIqbal Apr 3, 2023
5c7ddcb
Further Implemented Checker. Yet not complete.
NazirMuhammadZafarIqbal Apr 17, 2023
3953d68
Tried to get rid of Assertion Exception but couldn't succeed.
NazirMuhammadZafarIqbal Apr 25, 2023
b579fb7
Merge branch 'master' into MET07
NazirMuhammadZafarIqbal May 2, 2023
c850d23
Improved the implementation.
NazirMuhammadZafarIqbal May 7, 2023
3058c61
Merge branch 'master' into MET07
NazirMuhammadZafarIqbal May 7, 2023
7fabca9
Fixed the problem regarding the testing. Now build is successful.
NazirMuhammadZafarIqbal May 7, 2023
b9be053
Implemented few new test cases.
NazirMuhammadZafarIqbal May 14, 2023
991941e
Trying out some methods to detect method call with fully qualified na…
NazirMuhammadZafarIqbal May 14, 2023
001b4ed
Cleared out the trash code when experimenting in previous commit.
NazirMuhammadZafarIqbal May 14, 2023
777b8ff
Merge branch 'master' into MET07
NazirMuhammadZafarIqbal May 14, 2023
df8a6ba
Added changeLog.md.
NazirMuhammadZafarIqbal May 14, 2023
9c86374
Added comments for the main detector class.
NazirMuhammadZafarIqbal May 14, 2023
b8d0a96
Fixed a type in Javadoc.
NazirMuhammadZafarIqbal May 14, 2023
e623348
Applied a null check in `ReflectionIncreaseAccessibility.java` to run…
NazirMuhammadZafarIqbal May 15, 2023
31f07c3
Fixing whitespaces.
NazirMuhammadZafarIqbal May 15, 2023
84e0cef
Improved checker implementation by main method detection.
NazirMuhammadZafarIqbal May 16, 2023
484a273
Improved and tested logic of checker.
NazirMuhammadZafarIqbal May 18, 2023
3efa5de
Trying out minilist example of MailcapCommandMap and its superclass t…
NazirMuhammadZafarIqbal May 18, 2023
717b83d
As discussed in meeting, I reverted back to the exact matching of the…
NazirMuhammadZafarIqbal May 18, 2023
5ec2627
Commented out lines to make build successful.
NazirMuhammadZafarIqbal May 18, 2023
cc84241
Merge branch 'master' into MET07
NazirMuhammadZafarIqbal May 21, 2023
d64ab65
Improved and Implemented many new test cases.
NazirMuhammadZafarIqbal May 22, 2023
f2c0aa8
Implemented the Junit tests accordingly.
NazirMuhammadZafarIqbal May 22, 2023
285120f
Improved and changed the implementation. Now the checker is not exten…
NazirMuhammadZafarIqbal May 22, 2023
f483f07
Done!
JuditKnoll May 22, 2023
45aa398
Done!
JuditKnoll May 22, 2023
5e8913e
Done!
JuditKnoll May 22, 2023
2499a87
Done!
JuditKnoll May 22, 2023
f81faaa
Finalized the implementation approach, added comments, added auto gen…
NazirMuhammadZafarIqbal May 23, 2023
8b5f014
Finalized the implementation approach, added comments, added auto gen…
NazirMuhammadZafarIqbal May 24, 2023
efa1b4e
Deleted the invocation by fully qualified name test cases `GoodFindHi…
NazirMuhammadZafarIqbal May 24, 2023
d13a756
Added many non-compliant test cases.
NazirMuhammadZafarIqbal May 24, 2023
ad41e37
Fixed many non-compliant test cases according to new implementation.
NazirMuhammadZafarIqbal May 24, 2023
03dac3d
Added many new complaint test cases.
NazirMuhammadZafarIqbal May 24, 2023
7acdd04
Fixed many compliant test cases according to the new implementation o…
NazirMuhammadZafarIqbal May 24, 2023
2185c70
Deleted teh test cases which have been refactored.
NazirMuhammadZafarIqbal May 24, 2023
cd1fc64
Fixed the bug type naming convention in all the related files.
NazirMuhammadZafarIqbal May 24, 2023
8737202
Rewrote the short description, long description, and details of the bug.
NazirMuhammadZafarIqbal May 24, 2023
fdd5bb0
Improved the implementation of `isStringArray`.
NazirMuhammadZafarIqbal May 24, 2023
5d39298
Improved the implementation of `isStringArray`.
NazirMuhammadZafarIqbal May 24, 2023
aefce12
Fixed bug description.
NazirMuhammadZafarIqbal May 24, 2023
ff3a181
Reverting the array compression change.
NazirMuhammadZafarIqbal May 24, 2023
6d8ff65
Merged the conditional and made it equivalent by taking advantage of …
NazirMuhammadZafarIqbal May 24, 2023
3e756a2
Changed the message to sync with new implementation.
NazirMuhammadZafarIqbal May 24, 2023
9f0eb6c
Fixed white spaces.
NazirMuhammadZafarIqbal May 24, 2023
cea7c18
Reverted the null check in `ReflectionIncreaseAccessibility`
NazirMuhammadZafarIqbal May 24, 2023
49e0500
Apply 1 suggestion(s) to 1 file(s)
JuditKnoll May 24, 2023
0fe3922
Done!
JuditKnoll May 24, 2023
1dc124c
Changed the implementation of `isOverriding` to avoid NPE.
NazirMuhammadZafarIqbal May 24, 2023
380aeab
Done!
JuditKnoll May 24, 2023
f3a1f48
Suggested the solution to the problem in bug details message.
NazirMuhammadZafarIqbal May 24, 2023
f2b2658
Improved the implementation.
NazirMuhammadZafarIqbal May 24, 2023
00631bf
Merge branch 'master' into MET07
NazirMuhammadZafarIqbal May 24, 2023
4796df8
Merge remote-tracking branch 'origin/MET07' into MET07
NazirMuhammadZafarIqbal May 24, 2023
6971674
Used the `addClass()` and `addMethod()` instead of `addString()` on b…
NazirMuhammadZafarIqbal May 24, 2023
b7099fe
reverted the changes in non-relevant class caused mistakenly somehow.
NazirMuhammadZafarIqbal May 24, 2023
d4825bf
Improved logic and fixed bug reporting message.
NazirMuhammadZafarIqbal May 26, 2023
0bb206f
Deleted the extra empty or unneeded classes from the test cases.
NazirMuhammadZafarIqbal May 27, 2023
4797dc0
Removed the regex as there is no need for whitespace checking. Type h…
NazirMuhammadZafarIqbal May 31, 2023
480990e
Removed the regex as there is no need for whitespace checking. Type h…
NazirMuhammadZafarIqbal May 31, 2023
220c1f8
Revert "Removed the regex as there is no need for whitespace checking…
NazirMuhammadZafarIqbal May 31, 2023
584773e
Adjusted the test as wel - commenting changed the line number for rep…
NazirMuhammadZafarIqbal May 31, 2023
3d1423b
Used static final String constant in bcel library instead of String.
NazirMuhammadZafarIqbal May 31, 2023
f590f5a
Merge branch 'master' into MET07_AfterThesis
NazirMuhammadZafarIqbal May 31, 2023
7be2583
I renamed one of the classes in the test file according to the file n…
NazirMuhammadZafarIqbal Jun 5, 2023
8e28ef5
Fixed the Junit test file as per new class names in test cases.
NazirMuhammadZafarIqbal Jun 5, 2023
8e1888d
Merge branch 'master' into MET07
NazirMuhammadZafarIqbal Jun 5, 2023
ea30fab
Changed the String variable to final and adopted the naming conventio…
NazirMuhammadZafarIqbal Jun 7, 2023
3f76d53
Followed the convention of adding new checker's details in the end of…
NazirMuhammadZafarIqbal Jun 7, 2023
f47aa61
Fixed the comments issues.
NazirMuhammadZafarIqbal Jun 7, 2023
19df7e2
Merge branch 'master' into MET07
NazirMuhammadZafarIqbal Jun 11, 2023
6547799
Fixed extra "this" object reference in auxiliary method.
NazirMuhammadZafarIqbal Jun 11, 2023
d43f4e6
Fixed grammar error in comments.
NazirMuhammadZafarIqbal Jun 11, 2023
f75619d
Changed the Javadoc into comments for the mentioning the reason not t…
NazirMuhammadZafarIqbal Jun 11, 2023
ef2f3af
Merge branch 'master' into MET07
NazirMuhammadZafarIqbal Jun 16, 2023
64ce146
Fixed some issues with the comments.
NazirMuhammadZafarIqbal Jun 16, 2023
46efddb
Merge branch 'master' into MET07
NazirMuhammadZafarIqbal Jun 23, 2023
7a0398c
Done!
JuditKnoll Jun 23, 2023
637424b
Done!
JuditKnoll Jun 23, 2023
9c5f3bd
Followedconvention od class declaraion.
NazirMuhammadZafarIqbal Jun 23, 2023
50c7356
Fixed some comments.
NazirMuhammadZafarIqbal Jun 23, 2023
148730a
Merge branch 'MET07' of gitlab.inf.elte.hu:java-static-analysis/users…
NazirMuhammadZafarIqbal Jun 23, 2023
f5e7ce2
Fixed the error in bug line number due to changing the comments.
NazirMuhammadZafarIqbal Jun 26, 2023
a118fb2
Update messages.xml
NazirMuhammadZafarIqbal Jul 9, 2023
b770050
Merge branch 'master' into MET07
hazendaz Jul 22, 2023
1059c69
Update CHANGELOG.md
hazendaz Jul 22, 2023
1b932e8
Update CHANGELOG.md
hazendaz Jul 22, 2023
2d346b2
Update messages.xml
hazendaz Aug 19, 2023
b180d46
Update messages.xml
hazendaz Aug 19, 2023
4cc08fa
FIxed `isMainMethod` to follow new main method. https://openjdk.org/j…
NazirMuhammadZafarIqbal Sep 13, 2023
cdcdf81
Fixing, the operator precedance issues.
NazirMuhammadZafarIqbal Sep 13, 2023
ee92502
Merge branch 'master' into MET07
NazirMuhammadZafarIqbal Nov 12, 2023
38a62e3
Fixing, the project migration from JUnit Vintage to JUnit Jupiter.
NazirMuhammadZafarIqbal Nov 12, 2023
dbe1d00
Moved the statement to improve the efficiency of the code.
NazirMuhammadZafarIqbal Nov 12, 2023
b257c10
Fixed the checks for isMainMethod to abide by latest criteria.
NazirMuhammadZafarIqbal Nov 12, 2023
7cf9dab
Fixed the probable problem due to null value of superclasses variable…
NazirMuhammadZafarIqbal Nov 12, 2023
71d74a3
Moved the declaration of checker in `CHANGELOG.md` to unreleased sect…
NazirMuhammadZafarIqbal Nov 13, 2023
83cd5d5
Fixed the merge issue.
NazirMuhammadZafarIqbal Nov 13, 2023
5308f6f
Merge branch 'master' into MET07
NazirMuhammadZafarIqbal Nov 27, 2023
4e7e3f3
Inverted the loops to make the code efficient. Also adjusted the cond…
NazirMuhammadZafarIqbal Nov 27, 2023
660a5ff
Fixed some English grammar issues in comments.
NazirMuhammadZafarIqbal Nov 27, 2023
57544aa
Renamed the Checker name to more appropriate name. ALso, changed the …
NazirMuhammadZafarIqbal Nov 27, 2023
42843c0
Renamed the Checker name to more appropriate name. ALso, changed the …
NazirMuhammadZafarIqbal Nov 27, 2023
58741f9
Forgot the change in bug reporter. And renamed the assertion methods …
NazirMuhammadZafarIqbal Nov 27, 2023
58422fa
Changed checker name in `CHANGELOG.md`
NazirMuhammadZafarIqbal Nov 27, 2023
81399df
Updated master branch.
NazirMuhammadZafarIqbal Dec 3, 2023
d7c581b
Changed the description of detector.
NazirMuhammadZafarIqbal Dec 3, 2023
c1095a0
Update by IDE.
NazirMuhammadZafarIqbal Dec 3, 2023
6cc4453
Fixed spacing issues.
NazirMuhammadZafarIqbal Dec 3, 2023
ee646c2
Merge branch 'master' into MET07
NazirMuhammadZafarIqbal Jan 26, 2024
047d871
Fixed misleading comment issues.
NazirMuhammadZafarIqbal Jan 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -16,6 +16,9 @@ Currently the versioning policy of this project follows [Semantic Versioning v2.

- tbd

### Added
- New detector `FindHiddenMehtod` for bug type `HSM_HIDING_METHOD`. This bug is reported whenever a subclass method hides the static method of super class. (See [SEI CERT MET07-J] (https://wiki.sei.cmu.edu/confluence/display/java/MET07-J.+Never+declare+a+class+method+that+hides+a+method+declared+in+a+superclass+or+superinterface)).
JuditKnoll marked this conversation as resolved.
Show resolved Hide resolved

JuditKnoll marked this conversation as resolved.
Show resolved Hide resolved
## 4.8.1 - 2023-11-06

### Fixed
Expand Down
@@ -0,0 +1,177 @@
package edu.umd.cs.findbugs.detect;

import static edu.umd.cs.findbugs.test.CountMatcher.containsExactly;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasItem;

import org.junit.jupiter.api.Test;
import edu.umd.cs.findbugs.AbstractIntegrationTest;
import edu.umd.cs.findbugs.test.matcher.BugInstanceMatcher;
import edu.umd.cs.findbugs.test.matcher.BugInstanceMatcherBuilder;

class FindHiddenMethodTest extends AbstractIntegrationTest {
private final String BUG_TYPE = "HSM_HIDING_METHOD";

@Test
void testBadFindHiddenMethodTest() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the "bad" testcases, there could be an assert for the number of the found buginstances as well.

performAnalysis("findhiddenmethodtest/GrantAccessStatic.class",
"findhiddenmethodtest/BadFindHiddenMethodTest.class");
assertHSBCBug("displayAccountStatus", 15);
}

@Test
void testBadFindHiddenMethodTest2() {
performAnalysis("findhiddenmethodtest/BadSuperClass.class",
"findhiddenmethodtest/BadHidingVsOverriding.class");
assertHSBCBug("methodHiding", 19);
}


@Test
void testBadFindHiddenMethodTest3() {
performAnalysis("findhiddenmethodtest/SuperBadInEqualMultipleMethod.class",
"findhiddenmethodtest/BadInEqualMultipleStaticMethod.class");
assertHSBCBug("display", 25);
assertHSBCBug("display2", 29);
}

@Test
void testBadFindHiddenMethodTest4() {
performAnalysis("findhiddenmethodtest/BadMainMethodCheck.class",
"findhiddenmethodtest/BadSuperClassWithMain.class");
assertHSBCBug("main", 18);
}

@Test
void testBadFindHiddenMethodTest5() {
performAnalysis("findhiddenmethodtest/BadGrandClass.class",
"findhiddenmethodtest/BadParentClass.class",
"findhiddenmethodtest/BadMultiLevelInheritance.class");
assertHSBCBug("display", 20);
}

@Test
void testBadFindHiddenMethodTest6() {
performAnalysis("findhiddenmethodtest/SuperBadMultipleMethods.class",
"findhiddenmethodtest/BadMultipleStaticMethods.class");
assertHSBCBug("display", 19);
assertHSBCBug("display2", 23);
}

@Test
void testBadFindHiddenMethodTest7() {
performAnalysis("findhiddenmethodtest/SuperBadNonOrderedMultipleStaticMethods.class",
"findhiddenmethodtest/BadNonOrderedMultipleStaticMethods.class");
assertHSBCBug("display", 24);
assertHSBCBug("display2", 28);
}

@Test
void testBadFindHiddenMethodTest8() {
performAnalysis("findhiddenmethodtest/BadOuterInnerClass.class",
"findhiddenmethodtest/BadOuterInnerClass$BadInner.class");
assertHSBCBug("badMethod", 15);
}

@Test
void testBadFindHiddenMethodTest9() {
performAnalysis("findhiddenmethodtest/SuperBadProtected.class",
"findhiddenmethodtest/BadProtected.class");
assertHSBCBug("display", 15);
}

@Test
void testGoodFindHiddenMethodTest() {
performAnalysis("findhiddenmethodtest/GrantAccess.class",
"findhiddenmethodtest/GoodFindHiddenMethodTest.class");
assertNoHSBCBug();
}

@Test
void testGoodFindHiddenMethodTest2() {
performAnalysis("findhiddenmethodtest/SuperGoodInEqualMultipleMethod.class",
"findhiddenmethodtest/GoodInEqualNonStaticMethods.class");
assertNoHSBCBug();
}

@Test
void testGoodFindHiddenMethodTest3() {
performAnalysis("findhiddenmethodtest/GoodSuperClassWithMain.class",
"findhiddenmethodtest/GoodMainMethodCheck.class");
assertNoHSBCBug();
}

@Test
void testGoodFindHiddenMethodTest4() {
performAnalysis("findhiddenmethodtest/GoodGrandNonStatic.class",
"findhiddenmethodtest/GoodParentNonStatic.class",
"findhiddenmethodtest/GoodMultiLevelInheritanceNonStatic.class");
assertNoHSBCBug();
}

@Test
void testGoodFindHiddenMethodTest5() {
performAnalysis("findhiddenmethodtest/GoodGrandClassPrivate.class",
"findhiddenmethodtest/GoodParentClassPrivate.class",
"findhiddenmethodtest/GoodMultiLevelInheritancePrivate.class");
assertNoHSBCBug();
}

@Test
void testGoodFindHiddenMethodTest6() {
performAnalysis("findhiddenmethodtest/SuperMultipleNonStatic.class",
"findhiddenmethodtest/GoodMultipleNonStaticMethods.class");
assertNoHSBCBug();
}

@Test
void testGoodFindHiddenMethodTest7() {
performAnalysis("findhiddenmethodtest/SuperGoodMultipleStaticMethod.class",
"findhiddenmethodtest/GoodMultipleStaticMethod.class");
assertNoHSBCBug();
}

@Test
void testGoodFindHiddenMethodTest8() {
performAnalysis("findhiddenmethodtest/SuperGoodNonOrderedMultipleStaticMethods.class",
"findhiddenmethodtest/GoodNonOrderedMultipleNonStaticMethods.class");
assertNoHSBCBug();
}

@Test
void testGoodFindHiddenMethodTest9() {
performAnalysis("findhiddenmethodtest/GoodOuterInnerClassNonStatic.class",
"findhiddenmethodtest/GoodOuterInnerClassNonStatic$GoodInnerNonStaticGood.class");
assertNoHSBCBug();
}

@Test
void testGoodFindHiddenMethodTest10() {
performAnalysis("findhiddenmethodtest/GoodOuterInnerClassPrivate.class",
"findhiddenmethodtest/GoodOuterInnerClassPrivate$GoodInnerClassPrivate.class");
assertNoHSBCBug();
}

@Test
void testGoodFindHiddenMethodTest11() {
performAnalysis("findhiddenmethodtest/SuperGoodProtected.class",
"findhiddenmethodtest/GoodProtected.class");
assertNoHSBCBug();
}

private void assertNoHSBCBug() {
final BugInstanceMatcher bugTypeMatcher = new BugInstanceMatcherBuilder()
.bugType(BUG_TYPE)
.build();
assertThat(getBugCollection(), containsExactly(0, bugTypeMatcher));
}

private void assertHSBCBug(String methodName, int lineNumber) {
final BugInstanceMatcher bugTypeMatcher = new BugInstanceMatcherBuilder()
.bugType(BUG_TYPE)
.inMethod(methodName)
.atLine(lineNumber)
.build();
assertThat(getBugCollection(), hasItem(bugTypeMatcher));
}
}
5 changes: 5 additions & 0 deletions spotbugs/etc/findbugs.xml
Expand Up @@ -682,6 +682,9 @@
<Detector class="edu.umd.cs.findbugs.detect.DontReusePublicIdentifiers" speed="fast"
reports="PI_DO_NOT_REUSE_PUBLIC_IDENTIFIERS_CLASS_NAMES,PI_DO_NOT_REUSE_PUBLIC_IDENTIFIERS_FIELD_NAMES,PI_DO_NOT_REUSE_PUBLIC_IDENTIFIERS_METHOD_NAMES,PI_DO_NOT_REUSE_PUBLIC_IDENTIFIERS_LOCAL_VARIABLE_NAMES"
disabled="true"/>
<Detector class="edu.umd.cs.findbugs.detect.FindHiddenMethod" speed="fast"
reports="HSM_HIDING_METHOD"/>

<!-- Bug Categories -->
<BugCategory category="NOISE" hidden="true"/>
JuditKnoll marked this conversation as resolved.
Show resolved Hide resolved

Expand Down Expand Up @@ -714,6 +717,7 @@
<BugCode abbrev="ASE"/>
<BugCode abbrev="VSC"/>
<BugCode abbrev="DA"/>
<BugCode abbrev="HSM"/>
<!-- Bug patterns -->
<BugPattern abbrev="JUA" type="JUA_DONT_ASSERT_INSTANCEOF_IN_TESTS" category="BAD_PRACTICE" experimental="true" />
<BugPattern abbrev="AA" type="AA_ASSERTION_OF_ARGUMENTS" category="BAD_PRACTICE" />
Expand Down Expand Up @@ -1320,4 +1324,5 @@
<BugPattern abbrev="PI" type="PI_DO_NOT_REUSE_PUBLIC_IDENTIFIERS_METHOD_NAMES" category="BAD_PRACTICE"/>
<BugPattern abbrev="PI" type="PI_DO_NOT_REUSE_PUBLIC_IDENTIFIERS_LOCAL_VARIABLE_NAMES" category="BAD_PRACTICE"/>

<BugPattern abbrev="HSM" type="HSM_HIDING_METHOD" category="CORRECTNESS"/>
</FindbugsPlugin>
37 changes: 37 additions & 0 deletions spotbugs/etc/messages.xml
Expand Up @@ -1819,6 +1819,23 @@ factory pattern to create these objects.</p>
]]>
</Details>
</Detector>
<Detector class="edu.umd.cs.findbugs.detect.FindHiddenMethod">
<Details>
<![CDATA[
<p>
Hiding happens when a sub class defines a static method
with the same header (signature plus return type) as any of its super classes.
In the event 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 for method invocation for method hiding.
Moreover, method hiding and method overriding is often confused by programmers.
Consequently, programmers should avoid the method hiding.
Programmer should declare the respective method non-static or restrict it as private to eradicate the problem.
JuditKnoll marked this conversation as resolved.
Show resolved Hide resolved
</p>
]]>
</Details>
</Detector>

<!--
**********************************************************************
BugPatterns
Expand Down Expand Up @@ -9005,6 +9022,25 @@ Using floating-point variables should not be used as loop counters, as they are
]]>
</Details>
</BugPattern>
<BugPattern type="HSM_HIDING_METHOD">
<ShortDescription>Method hiding must be avoided.</ShortDescription>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Should" rather than "must".

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

<LongDescription>The method '{1}' in class '{2}' hides a method in class '{3}'. Declare the respective methods non-static or private to eradicate the problem.</LongDescription>
<Details>
<![CDATA[
Hiding happens when a sub class defines a static method
with same header (signature plus return type) as in any of the super classes.
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 for 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.
JuditKnoll marked this conversation as resolved.
Show resolved Hide resolved
<p>
See SEI CERT rule <a href="https://wiki.sei.cmu.edu/confluence/display/java/MET07-J.+Never+declare+a+class+method+that+hides+a+method+declared+in+a+superclass+or+superinterface">MET07-J. Never declare a class method that hides a method declared in a superclass or superinterface</a>.
</p>
]]>
</Details>
</BugPattern>
<BugPattern type="PI_DO_NOT_REUSE_PUBLIC_IDENTIFIERS_CLASS_NAMES">
<ShortDescription>Do not reuse public identifiers from JSL as class name</ShortDescription>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"name" -> "names"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is from another already accepted PR #2511, which got here when merging master to this branch. I proposed some changes to the messages in #2689.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am skipping it.

<LongDescription>The name of the class {0} shadows the publicly available identifier from the Java Standard Library.</LongDescription>
Expand Down Expand Up @@ -9263,4 +9299,5 @@ Using floating-point variables should not be used as loop counters, as they are
<BugCode abbrev="VSC">Vulnerable security check performing methods</BugCode>
<BugCode abbrev="AA">Misuse of assertions for checking arguments of public methods</BugCode>
<BugCode abbrev="PI">Do not reuse public identifiers from Java Standard Library</BugCode>
<BugCode abbrev="HSM">Avoid method hiding</BugCode>
</MessageCollection>