Affects PMD Version: 7.17.0
Rule:
Please provide the rule name and a link to the rule documentation:
ConstructorCallsOverridableMethod
https://pmd.github.io/pmd/pmd_rules_java_errorprone.html#constructorcallsoverridablemethod
Description:
[WARNING] PMD Failure: Inner:15 Rule:ConstructorCallsOverridableMethod Priority:1 Overridable method called during object construction: TestOverridableNestedClass.value().
Code Sample demonstrating the issue:
public class TestOverridableNestedClass {
public Inner createInner() {
return new Inner();
}
public String value() {
return "42";
}
class Inner {
private final String value;
Inner() {
this.value = value();
}
public String getValue() {
return value;
}
}
}
Expected outcome:
No violation, the call to value() is on a fully-constructed instance of the enclosing class, not the under-construction inner class.
Running PMD through: Maven
Affects PMD Version: 7.17.0
Rule:
Please provide the rule name and a link to the rule documentation:
ConstructorCallsOverridableMethod
https://pmd.github.io/pmd/pmd_rules_java_errorprone.html#constructorcallsoverridablemethod
Description:
Code Sample demonstrating the issue:
Expected outcome:
No violation, the call to
value()is on a fully-constructed instance of the enclosing class, not the under-construction inner class.Running PMD through: Maven