What is the difference between modifies this, modifies this.x, and modifies this`x?
Question
What is the difference between modifies this
, modifies this.x
, and modifies this`x
?
Answer
A modifies
clause for a method lists object references whose fields may be modified by the body of the method.
this
means that all the fields of thethis
object may be modified by the bodythis.x
(wherex
is a field ofthis
and has some reference type) means that fields ofx
may be modified (but not the fieldx
itself ofthis
)this`x
means that just the fieldx
ofthis
may be modified (and not any other fields, unless they are listed themselves)
If there are multiple items listed in the modifies clause, the implicit clause is the union of all of them.
More on framing (modifies
and reads
clauses) can be found in the reference manual section on Framing specifications.