author and iconoclast
posted 12 years ago
Well, then you'd have to throw a RuntimeException of some kind with an explanatory message. Note, though, that you need to think a bit about why you're doing this. If class A can be cloned, and B is a subclass, then it's reasonable to expect B to be cloneable too. Since it's not, B isn't really a kind-of A, is it? This is a violation of the "Liskov Substitution Principle" (LSP) which some folks believe it a good litmus test for inheritance. Are you sure B should extend A? Maybe B should simply contain an instance of A and forward some method calls to it. Is there an interface that A implements that B can implement this way by delegation?