IAmYourFaja
IAmYourFaja

Reputation: 56934

How to code with JCIP (Java Concurrency in Practice)

Recently read up on JCIP annotations and they seem cool. Went to the website and took a look at the source. The only problem is that the src jar just contains the annotations...I'm not seeing where I can find the annotation processors that actually do anything! Am I just looking in the wrong place, or are these not real Java annotations (meaning, is there no way to enforce @Immutable when it is used to mark a class)?

Upvotes: 11

Views: 2556

Answers (3)

MiguelMunoz
MiguelMunoz

Reputation: 4952

The IntelliJ IDE will use these annotations to look for bugs in your code. If you annotate a variable is @GuardedBy(some_lock), the IDE will flag cases where you access it without properly synchronizing on it. This is very useful.

Upvotes: 4

Victor Grazi
Victor Grazi

Reputation: 16510

The JCIP annotations are a formal way to document a concurrency contract such as this member is "@GuardedBy" this field.

They don't do anything functionally in your code.

Upvotes: 1

JB Nizet
JB Nizet

Reputation: 692023

FindBugs supports those annotations. The support for those annotations and others is described in this documentation page.

Upvotes: 11

Related Questions