Closed reprogrammer closed 12 years ago
@Wanderer777, @reprogrammer: When I get the pointed instances of a lock object used in a synchronized block, WALA returns me a node with the type of NormalAllocationNode
.
When the lock object is an auto-boxed Integer
such as Integer a = 3;
and I call normalAllocationNode.getNode().getMethod()
WALA just gives me valueOf
. However, it should return both Integer.IntegerChache
and Integer.valueOf
because some of the auto-boxed Integer
's are created in Integer.valueOf
while some others are created in the static initializer of Integer.IntegerCache
.
LCK01J describes bad synchronizations that use reusable objects as locks.
This is a fairly simple bug pattern to detect for it doesn't require interprocedural data flow analysis.
However, it isn't sufficient to check the type of lock objects to accurately detect LCK01J. For example, boolean literals (
Boolean.FALSE
andBoolean.TRUE
) are reused butnew Boolean(false)
andnew Boolean(true)
aren't. Similarly, boxed primitives may be reused but non-box Integers may not. Likewise, string literals such as"STRING_LITERAL"
and interned strings such asnew String("STRING_LITERAL").intern()
are reused but string objects such asnew String("STRING_LITERAL")
are not.