Yesterday I released findbugs-slf4j v1.2.0, which supports more useful analysis based on OpcodeStackDetector
.
Here I will summarize my problem and solution.
What is TOP?
Problem is that my detector could not track state of OpcodeStack
, because stack becomes TOP. I cannot get elements in stack. if stack is TOP.
What TOP means? It comes from the lattice. You may refer following papers for detail:
- http://web.cecs.pdx.edu/~juncao/links/doctoral/Bib/RHS96.pdf
- http://www.bodden.de/pubs/bodden12inter-procedural.pdf
In context of my plugin, it means that findbugs plugin cannot decide state of Item
when it joins separated operation flows (e.g. after for-loop, after if-block and in catch-block). So I cannot get Item
from OpcodeStack
.
How to define join
operation for FindBugs?
Check merge(Item, Item)
method in OpcodeStack
.
But if you use userValue
in Item
, it should be hard to join Item
because this merge
method just compares two userValue
and set it to merged Item
only when two Item
s are equal.
What can be solution?
In my case, I stopped using userValue
. There are some alternative solutions:
specialKind
defined inItem
might be good way to markItem
- It has different and complex logic to merge two
Item
s
- It has different and complex logic to merge two
- Use methods in
Item
class, if FindBugs already track and hold its state- In my case,
Item#getJavaClass()
replaced userValue
- In my case,