[FB-Discuss] Use of @ThreadSafe or @Immutable on a field?

David Smiley @MITRE.org DSMILEY at mitre.org
Mon Oct 27 14:40:08 EDT 2008

I'm trying to apply some annotations to my code to let FindBugs better check
for problems (and not report non-problems).  I have a Calendar object that I
am sure is in a state that is thread-safe, given that I will not call any
mutator methods:

	public static final Calendar UTC;
        static {
		//Note: "UTC" is now the "proper" way of dealing with zulu time (was
		UTC = GregorianCalendar.getInstance(TimeZone.getTimeZone("UTC"));
		UTC.getTimeInMillis();//side effect of internal initialization

I'd like to be able to annotate UTC with something so that FindBugs stops
telling me about the infamous problem of Calendar's not being threadsafe. 
Unfortunately, I can't annotate this field with @ThreadSafe or @Immutable
because both are for class-level annotations; not fields.

Does anyone have any thoughts on this?

~ David Smiley
View this message in context: http://www.nabble.com/Use-of-%40ThreadSafe-or-%40Immutable-on-a-field--tp20192711p20192711.html
Sent from the findbugs-discuss mailing list archive at Nabble.com.

More information about the Findbugs-discuss mailing list