Description
Currently, SourceChecker.getMessagesProperties() only traverses the class hierarchy of the checker itself (via Class.getSuperclass() up to SourceChecker). It does not consult any parent checker (getParentChecker()).
Consequently, subcheckers that report diagnostic keys defined in a parent checker's messages.properties (or subcheckers run as part of an aggregate/compound checker) must manually override getMessagesProperties() to load the parent checker's properties file.
For example, in RLCCalledMethodsChecker:
@Override
public Properties getMessagesProperties() {
Properties result = super.getMessagesProperties();
// RLCCalledMethodsVisitor reports keys that only the Resource Leak Checker's
// messages.properties defines -- required.method.not.called and owning.override.return
// among them. getMessagesProperties walks this checker's *class* hierarchy
// (RLCCalledMethodsChecker, CalledMethodsChecker, AccumulationChecker, ...), which does
// not include ResourceLeakChecker, since this checker is its subchecker rather than its
// subclass. Without this, every such message is printed as its bare key.
result.putAll(getProperties(ResourceLeakChecker.class, MSGS_FILE, true));
return result;
}
Proposed Solution
In SourceChecker.getMessagesProperties(), when parentChecker != null, properties from parentChecker.getMessagesProperties() should also be included (with the subchecker's own messages taking precedence if there are key conflicts).
This would eliminate the need for subcheckers to manually look up and load their parent checkers' messages.properties.
Description
Currently,
SourceChecker.getMessagesProperties()only traverses the class hierarchy of the checker itself (viaClass.getSuperclass()up toSourceChecker). It does not consult any parent checker (getParentChecker()).Consequently, subcheckers that report diagnostic keys defined in a parent checker's
messages.properties(or subcheckers run as part of an aggregate/compound checker) must manually overridegetMessagesProperties()to load the parent checker's properties file.For example, in
RLCCalledMethodsChecker:Proposed Solution
In
SourceChecker.getMessagesProperties(), whenparentChecker != null, properties fromparentChecker.getMessagesProperties()should also be included (with the subchecker's own messages taking precedence if there are key conflicts).This would eliminate the need for subcheckers to manually look up and load their parent checkers'
messages.properties.