google / google/error-prone

Annotation idea: WritesGuardedBy

Open
#1,280 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
7.2k
Forks
820
Avg merge
5h 9m
Merged PRs (30d)
50

Description

### Description of the problem / feature request:

`WritesGuardedBy` annotation for fields that should be only written when a lock is held, but there can be reads outside of critical section. Example use: double-checked locking pattern.

### Feature requests: what underlying problem are you trying to solve with this feature?

Provide a way to concisely express "this variable is updated/stored (lazily) within double-checked locking" in code. Add a tool to improve the safety of such patterns (nobody will be able to accidentally write to the field outside a critical section).

### Have you found anything relevant by searching the web?

No

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.