A method is called during object construction if it is inside a:
clone()
methodreadObject()
methodreadObjectNoData()
methodMethods are overridable if they are not declared as final
, static
, or private
.
Package-local methods are considered safe, even though they are overridable. Such calls may result in subtle bugs,
as object initialization may happen before the method call.
Example:
class Parent {
void someMethod() { }
}
class Child extends Parent {
Child() {
someMethod();
}
}
This inspection shares the functionality with the following inspections:
Only one inspection should be enabled at once to prevent warning duplication.