Skip to content

Dealing with libraries

David Bürgin edited this page Nov 4, 2015 · 18 revisions

Dealing with libraries

We have eliminated two errors and with that two bugs, but there are still 35 more to go. But there's a realisation to be had in the next few error messages, and it will cut down our work considerably.

The topmost errors are again in Owner LINK. The Checker outputs an error on every append call in the following code.

@Override
public String toString() {
    return new ToStringCreator(this)
            .append("id", this.getId())
            .append("new", this.isNew())
            .append("lastName", this.getLastName())
            .append("firstName", this.getFirstName())
            .append("address", this.address)
            .append("city", this.city)
            .append("telephone", this.telephone)
            .toString();
}

The error is

[argument.type.incompatible] incompatible types in argument.
  found   : @Initialized @Nullable String
  required: @Initialized @NonNull Object

The assumption that all references are non-null by default makes an other appearance, but this time in code that we don't control. The append calls are on an org.springframework.core.style.ToStringCreator object. Apparently, since the author of the code recklessly passes in nullable references to append, this ToStringCreator is null-tolerant. We would have to check the documentation of this class to make sure the code is correct as it is.

... talk about skipUses

Clone this wiki locally