-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[java] AccessorMethodGeneration: Name clash with another public field not properly handled #342
Copy link
Copy link
Closed
Labels
a:false-positivePMD flags a piece of code that is not problematicPMD flags a piece of code that is not problematicin:symbol-tableAffects the symbol table codeAffects the symbol table codein:type-resolutionAffects the type resolution codeAffects the type resolution code
Milestone
Description
Rule Set: AccessorMethodGeneration (Java - Design), PMD 5.5.5
Description:
It appears that the rule AccessorMethodGeneration fails to resolve name clash with public field in another class with identical name.
Code Sample demonstrating the issue:
public class ClassA {
public String field;
}public class ClassB {
private String field;
private class ClassC {
public void doSomething() {
ClassA a = new ClassA();
a.field = "abcd"; // should not be a violation here but reported as one
}
}
}Changing ClassB#field to e.g. ClassB#field0 removes the violation.
Running PMD through: Gradle
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
a:false-positivePMD flags a piece of code that is not problematicPMD flags a piece of code that is not problematicin:symbol-tableAffects the symbol table codeAffects the symbol table codein:type-resolutionAffects the type resolution codeAffects the type resolution code