I wonder if there's a simple way to to find all methods accessing a field directly. More precisely:
I'd like to assure that there's exactly one method writing a field and exactly one method reading it. All other accesses should use these two.
Background: When a field gets written, I need to record the fact somewhere I can do this easily using a generated setter, but I'd like to assure that I don't circumvent it somewhere.
It's for mobile rather than server, so I don't want / can't use interfaces or run-time bytecode rewriting...
I know, there's ASM, but AFAIK using it means more work that I'd like to spend. I hope, there's a better way.
Update
I didn't think of it, but have to state that code changes are allowed, but memory is tight. So encapsulating fields (e.g., Java FX style) or making a backup is too bad. There are quite a few fields, so actually anything requiring to touch them all is not good.
I could imagine parsing the sources, which is either complicated or prone to false positives as the same identifier has different meanings depending on the context. It may be even shadowed (e.g., in a nested class declaring an equally-named variable), but then I'd gladly change the code to avoid the problem.
Getting a structured information from the class file would surely be better.