I am attempting to update an application that uses dependency injection, in doing so, I am trying to document each class (that needs it) with a "thread-safety" annotation, both for other coders and for bug checkers.
If I have a service class, as follows:
@ImplementedBy(FooImpl.class)
public interface FooSrvc {
}
and it's associated implementation
class FooImpl implements FooSrvc {
}
*Should I document or annotate both the Interface and the concrete Implementation with thread-safe annotations? Just the service, because it's public, just the implementation?*e.g. for both:
@javax.annotation.concurrent.ThreadSafe
@org.checkthread.annotations.ThreadSafe
@ImplementedBy(FooImpl.class)
public interface FooSrvc {
}
@javax.annotation.concurrent.ThreadSafe
@org.checkthread.annotations.ThreadSafe
class FooImpl implements FooSrvc {
}
Note - I am using two different thread-safety annotation sets to use an older concurrency bug finder CheckThread (where I couldn't find documentation that supports the jsr-305 annotations) and FindBugs.
Thank you.