History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: IDEABKL-4936
Type: New Feature New Feature
Status: Open Open
Priority: Major Major
Assignee: Maxim Shafirov
Reporter: Peter Lawrey
Votes: 0
Watchers: 0
Available Workflow Actions

Mark as Stalled
Operations

If you were logged in you would be able to see more operations.
IDEA: Backlog

Mark classes, parameter and methods as Immutable/Mutable/ThreadSafe/NotThreadSafe

Created: 27 Nov 06 14:55   Updated: 21 Dec 06 18:19
Component/s: Code Analysis. Inspection
Affects Version/s: None
Fix Version/s: None

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown

Build: 6,104


 Description  « Hide
Have rules which can static check the validity of Immutable/Mutable ThreadSafe/NotThreadSafe. Annotations should be RUNTIME to allow container to perform additional dynamic checks.
This illustrates the rules which could be used to statically check thread safety This could improve the quality of multi-threaded code.

Immutable:
classes - cannot be changed and are thus thread safe. No mutable method can be called and it and its fields cannot be passed as a Mutable parameter. An immutable class is ThreadSafe.
parameters - means a parameter will not be changed. No Mutable methods can be called on it, nor can be passed to a mutable parameter.
methods - means a method does not alter "this" No calls to method which alter this are allowed.

Mutable:
classes - can be altered. Assumed to be NotThreadSafe unless marked as ThreadSafe.
parameters- means a parameter could be altered. Not valid if it is not altered.
methods - could alter "this". Not valid in an Immutable class.

ThreadSafe:
class - is mutable but thread safe.
parameter - assumes the parameter is thread safe. NotThreadSafe cannot be used.

NotThreadSafe:
class - is mutable. Cannot be used in context which assume thread safety.
parameter - Make no assumption about thread safety./



 All   Comments   Work Log   Change History      Sort Order:
Maxim Shafirov - 21 Dec 06 13:56
There's a JSR-305 ongoing, which we (JetBrains) take part in. Hopefully, this JSR will cover this kind of annotations but I'm not sure the semantics will be exactly the same so we probably hold on with this until the things are clarified.

Peter Lawrey - 21 Dec 06 18:19
One thing I find is lacking from Java is the ability for annotations to extend each other....
In the JSR-305 examples plain interfaces are used and they extend each other....

In the mean time I have IoC container which uses these annotations to ensure components are writed up in a thread safe way. Components which are NotThreadSafe can only be used in a single threaded context.