InspectionGadgets: erroneous error reported for unsync access to immutable field

IG erroneously reports an error when a field of an immutable type (such as a static final primitive or a string or other java.lang.* class) is acccessed from both synchronized and unsynchronized contexts.

For example, the following code:

private static final String DEFAULT_EXT = ".xpdl";
private static final long pollInterval = Long.getLong(POLLINTERVAL, 5000).longValue();

results in the following messages:

"Field DEFAULT_EXT is accessed in both synchronized and synchronized contexts" and
"Field _pollInterval is accessed in both synchronized and synchronized contexts"

1 comment


Yup, that's a bug alright. I'd say that any "final" variable should be ignored for purposes of that inspection, actually. I'll put in a fix in the next version.

--Dave Griffith

0

Please sign in to leave a comment.