Here is a question which for some reason I feel very unsure with. Can you guys take a look and see if you agree or disagree with what I have?
I personally think that the below situation is safe and secure:
Your software company has produced the following Unique class definition attempts to capture the idea of an object having a unique identification number associated with it. Clients needing such a feature will subclass this class. However in the contract the clients have insisted a security guarantee: if someone can create two instances of a particular subclass of Unique that claim (via getIdentificationNumber method) to have the same identification number, you lose A LOT of money...
public class Unique {
private static long count = 0;
private final long identificationNumber = count ++;
public long getIdentificationNumber() {
return identificationNumber;
}
}
Are there any flaws, and if so how can they be fixed?