typetools / typetools/checker-framework

@GuardSatisfied on array elements

Open
#917 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

False Positive (false warning or imprecision)
Dominant language
Java
Stars
1.1k
Forks
440
Avg merge
1d 12h
Merged PRs (30d)
134

Description

The Lock Checker forbids using @GuardSatisfied on an array element type; you get a warning message such as:

GuardSatisfiedArray.java:7: error: [guardsatisfied.location.disallowed] @GuardSatisfied annotations are only allowed on method return types, receivers and parameters.
    void bar(@GuardSatisfied Object[] args) {
             ^
1 error

I believe that @GuardSatisfied should be permitted on all components of a return or formal parameter type. This includes array element types.

I don't remember a theoretical reason why @GuardSatisfied is not permitted on non-top-level components -- that is, I don't see a type loophole.

There is a test case in file checker/tests/lock/GuardSatisfiedArray.java .

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with checker/tests/lock/GuardSatisfiedArray.java and run the Lock Checker test that demonstrates the current diagnostic. Trace the Lock Checker handling of @GuardSatisfied locations and determine how array element types are rejected. Done means the test permits @GuardSatisfied on array elements of return or formal parameter types without emitting the disallowed-location error.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.