Skip to content

Inherit messages.properties from parent checkers in SourceChecker.getMessagesProperties() #2153

Description

@wmdietl

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions