I noticed that over time again and again I find bugs (coded by me as well as lots of other people) in usage of EntityManager.merge() or similar methods (e.g. in my current large project using another O/R mapping framework).
The problem is that once you merged an object it is almost always a bug to re-use the same object instance.
You should instead use the return value.
Note that it is somewhat similar to the class of "return value is not used" problems (e.g. on BigDecimal or String), but it actually differs:
In case of merge() et.al. it is ok not to use the return value at all if the object is not needed, but it is not ok to continue using parameter after the method call.
So what if there were an annotation to say this parameter is "@Spoiled" by the method call - it should no longer be used:
Do you think that's useful? Should I create a Jira issue?
Is something like that discussed in JSR 305? (There isn't a public draft, yet, but JetBrains is a member of the expert group, so maybe somebody can comment on this.)