First page Back Continue Last page Summary Text

Notes:


This is about as simple an implementation as can be imagined – and it might even be exception safe!
For it to be strongly exception-safe we need to make the following assumptions:
The clone() methods themselves are strongly exception safe; and,
The PartOne and PartTwo objects do not own resources; and,
the clone() method called in the second line won't throw an exception (the nothrow guarantee).
These assumptions range from the reasonable - if one of the clone() methods propagates an exception while leaking a resource there is nothing that copyValueOf() can do to release it – to the unreasonable – a java.lang.OutOfMemoryError exception is clearly a possibility.
[[As an exercise for the reader which assumptions are required to give the weak exception-safety guarantee?]]


Lets deal with the last of these assumptions first...