The following declaration of entities was used:

entity Notification {
owner			-> User	(
						validate(owner != null, "FAIL! No notification without an owner!")
						)
}
entity FriendshipNotification : Notification {
item			-> Friendship	(
								validate(item != null, "FAIL! No FriendshipNotification without friendship")
								)
}

And the following code was executed, with n being a FriendshipNotification:

n.owner.notifications.remove(n);

This crashed with a nullpointer exception in java, which was tracked to dereferencing the owner. Turns out that n.owner was in fact null, but never caught. This was shown both by hacking debug statements into the generated java and by rewriting the entity declarations:

entity Notification {
}
entity FriendshipNotification : Notification {
owner			-> User	(
						validate(owner != null, "FAIL! No notification without an owner!")
						)
item			-> Friendship	(
								validate(item != null, "FAIL! No FriendshipNotification without friendship")
								)
}

And all of a sudden it works. So much for inheritance!

Submitted by Thomas Schaap on 31 March 2010 at 22:55

Log in to post comments