PackedPositionSequence is not fully immutable as e.g. the setOrdinate method changes the object state in place. However, the clonemethod returns this which means calling clone and setOrdinate on the cloned instance changes the state of the original sequence as well.
One case where this is actually a problem is when calling reverse on a JTS LineString backed by a PackedPositionSequence. Normally the expectation of that call is is creates a new LineString and leaves the original unchanged but as the PackedPositionSequence is not immutable but clone returns this, you end up having two LineStrings reversed, not just one.
PackedPositionSequence is not fully immutable as e.g. the
setOrdinate
method changes the object state in place. However, theclone
method returnsthis
which means callingclone
andsetOrdinate
on the cloned instance changes the state of the original sequence as well. One case where this is actually a problem is when callingreverse
on a JTSLineString
backed by aPackedPositionSequence
. Normally the expectation of that call is is creates a newLineString
and leaves the original unchanged but as thePackedPositionSequence
is not immutable but clone returnsthis
, you end up having twoLineStrings
reversed, not just one.