protected void finalize() {
this.addressBook.remove(this.lover.name);
while (this.lover.pictures.size() > 1) {
this.lover.pictures.remove(1);
}
Person heir;
heir = this.family.get(this.family.indexOf("sister"));
heir.give(this.assets.remove("sorrow"));
heir = this.family.get(this.family.indexOf("mother"));
heir.give(this.assets.remove("faith"));
heir = this.lover;
heir.give(this.assets.remove("innocence"));
this.assets.removeAllElements();
}
|
You were my last connection.
Now I am adrift,
washed by this city rain
through cold tunnels of guilt
out to a dark and glittering sea.
I have torn your name from my address book.
I have burned all your pictures, but one.
On my sister's grave, I left my sorrow.
In my mother's kitchen, I left my faith.
In your arms, I left my innocence,
all those years ago.
Now I am hollow and empty,
with nothing left to leave.
|
Termination
is inspired by the idea of reaching some end, some point where there are no more references to us to keep us viable. And as our resources are recollected by the system, we have to release those attributes that have so long defined us. This is the onlyProcess
that was born as a poem, and only then translated into code.Termination
is written in Java 1.5. Java is a high-level, object-oriented language, which makes it one of the most expressive languages for codework like this, since we often think of the world in terms of objects, with their various states ("variables") and behaviors ("methods").The full code will compile, but it does not actually do anything because there is no
main
method. In a complete system, the empty classes would need to be defined. Also,Person
would need a constructor that sets up all assets that are being removed here in thefinalize
method in order to avoid errors. Strictly speaking, the work done infinalize()
is not necessary, as all the particular objects contained by aPerson
here have nothing about them that would prevent them from being automatically garbage-collected along with thePerson
.The translation to code raises some questions. For instance, the
while
loop that removes all the pictures--should it leave the first, the last, or some other picture behind? Also, it currently removes the pictures held by the lover object, rather than the pictures of the lover held by the garbage-collected person. An interesting distinction, though the original poem allows for either of these readings.