There seems to be a consensus that Java's clone is broken to the extent that it should never be used if at all possible.
I have a situation where it seems like clone is the right tool, but I'm wondering if there's another way:
I have a variety of objects stored in a mongo database. They are saved and loaded using Morphia, which automagically returns objects with their correct class and properties.
In some cases, what is stored in the database is a "prototype" for an object that I want to create copies of. It comes out of morphia with the correct class and default values, and I want to be able to make a copy that preserves the class and default values. E.g.:
achievementPrototype = morphia.get(id);
playerAchievements.add(achievementPrototype.clone());
Where achievementPrototype is of a class that's a concrete implementation of an AbstractAchievement. It seems like clone does what I want. I'm aware that if achievements have objects as properties I'll have to implement their cloning, but I'm okay with that.
Should I use clone()? If not, what should I use?