Skip to content

nullness defaults for binaries #51

Description

@davidcok

JML adopted a nonnull-by-default semantics some time ago.

I think it clear that this applies to user-written Java source code. In that case any JML tool can check that the source obeys such a specification and can annotate it accordingly if there are declarations that are allowed to be null.

My question is about library (binary) classes. Consider a library method that returns a reference. This being Java, the reference may or may not be null. Of course, we can always write a .jml specification that makes it clear whether the method may return null or not. But what should the default specification be for a binary, source-code-less class (without an explicit JML specification)?

  • The default could be non_null because that is the general default in JML.
  • The default could be nullable because to presume otherwise is unsound and would cause missed errors in verification. A user's incorrect assumption that the return value is non-null would not be corrected by a failing verification because the default was also wrong.

I think I'm voting for the second policy for the default specification for binary classes, even though the default would now be different for binary and source classes.

Or to complicate things -- I'd be in favor of: formal parameters are non_null by default but return values are nullable by default, again, in the absence of any explicit specification or source code.

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