Skip to content

Should we have a reference implementation? #92

Closed

Description

@kevinb9n

.... whose only job is to be a reference implementation?

Activity

  1. cpovirk commented on Jan 24, 2020

    @cpovirk
    Collaborator

    I can see coming at this from either of 2 angles:

    1. Take some existing tool with similar semantics (probably the Checker Framework), and tweak it to match our desired semantics.
      + relatively easy to put together something workable quickly
      + progress toward support in the Checker Framework itself

    2. Write a tool from scratch.
      + ensures that we actually implement everything from the spec -- and only things from the spec, rather than "accidentally" inheriting implementations of functionality we didn't realize we needed to cover

    If we mainly want for users to be able to try out our annotations, then (1) seems more expedient.

    If we want to get in-depth validation of our spec, then the full work of (2) may be important.

  2. mernst commented on Jan 27, 2020

    @mernst
    Contributor

    I lean against having a reference implementation (whether an adaptation of an existing tool or a new tool).
    When there is a reference implementation, users tend to treat its output as an oracle and they believe that any other output is incorrect. However, we have a very weak specification for what a tool is supposed to report. Both false positives and false negatives are permitted, and some tools may intentionally choose analysis algorithm that lead to those.

    I am in favor of a test suite. It can check that the tool rejects invalid programs (those with annotations in illegal locations, or with conflicting annotations) and perhaps a few other weak properties.

    I am also in favor of not finalizing the specification until at least two (and probably more) third-party implementations exist. These will probably be specializations of existing analyses from IDEs or linting tools.

  3. cpovirk commented on Jan 27, 2020

    @cpovirk
    Collaborator

    The background as I understand it: There are release-planning discussions coming about whether we can release the spec without any implementations -- and then, if not, whether we can release with only a reference implementation.

    I think everyone would ideally like to see implementations first, but everyone would ideally like to see the annotations adopted in libraries first, too, for further validation. Yet we'd also like to see a release this year, which doesn't appear likely if we wait for all that. (Releasing this year might not appear likely even if we don't wait, depending on how pessimistic you are.)

    Hopefully the forthcoming release-planning discussions will give us an idea of what specific tasks we have left for the spec (and how long they'll take) -- as well as what specific tasks tool developers would have left for implementing it. Currently, I feel like we all have different ideas of what we have left and how long it would take. Plus, I don't know how much time various tool developers have to dedicate to this project over the coming months. If we were to discover that the tools could be 99% done before the spec is finalized, that would make the decision a lot easier :)

    The points about the weak specification are also good ones: We wouldn't want users to see one tool as an "oracle." You mentioned a test suite: We will soon need to rethink our proposed test-data format. Its initial list of "categories of warnings" should perhaps contain only the "ca-invalid-place" warning that you mentioned.

    I do think that we'll need something beyond that, but the current list of specific warnings like "ca-nullable-to-not-null" may not be the best approach. In particular, I think that we should have tests related to substitution rules, since we've been having a lot of discussion about those recently. However, it's possible that the word "tests" is the wrong one here: If tools can interpret the annotations in different ways, we want to leave some flexibility, while ideally also providing various "example interpretations" for people to consider when they write their checkers.

    That said, I don't know if flexibility in substitution rules is really something we'd want to encourage. However, two tools might disagree on the nullness of a particular expression or type usage for various reasons unrelated to substitution, so I'm not sure how we can test substitution without potentially testing other behavior.

  4. cpovirk commented on Jan 27, 2020

    @cpovirk
    Collaborator

    Coincidentally, I just gave this example of code that users are likely to want tools to treat as unsafe:

    class Foo<
        T extends @Nullable Object,
        U extends @Nullable T>
      T cast(U u) {
        return u;
      }
    }

    That would let a Foo<@NonNull Object, @Nullable String> cast a @Nullable String to a @NonNull Object.

    I think this falls into the category of things that would make good "example interpretations" to demonstrate rules that tools could consider adopting. But it does not fit into my model of demonstrating only substitution rules: What we'd be demonstrating here is a possible conversion rule -- again, like what's currently laid out in the proposal for the test-data format.

    I'm not sure of the right approach here. Maybe we need multiple tiers of tests and examples (annotation legality, substitution only, full conversions, others?) so that each test/example can use the features it needs while excluding others, minimizing the risk of triggering tool-specific features? Or maybe we just try to make every test/example clear about exactly what is required and what is not?

    (This all connects to #73, of course.)

  5. kevin1e100 commented on Feb 7, 2020

    @kevin1e100
    Collaborator

    FWIW I think if you recast things as "is this method a valid override of that method?" then maybe it's more clearly something we can ask checkers to adhere to.  We could have 3 classes of override "examples"/tests:

    • overrides that are clearly valid: e.g., return type strengthened from @Nullable to @NonNull
    • overrides that are clearly invalid: e.g., the opposite: return type weakened from @NonNull to @Nullable
    • overrides that are allowed, but tools may grumble: e.g., return type weakened from @NonNull to @NullnessUnspecified (specifically, that's unannotated code that overrides a method with @NonNull return type).
  6. kevinb9n commented on May 20, 2020

    @kevinb9n
    CollaboratorAuthor

    I agree with Mike. Instead of an RI, we will have test data and a coordinated release schedule with major implementors.

  7. added
    meta
    on Nov 30, 2022
  8. added this to the Release-independent milestone on Dec 2, 2022
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

    meta

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions