I want to make sure that a given group of objects is immutable.
I was thinking about something along the lines of:
- check if every field is private final
- check if class is final
- check for mutable members
So I guess my question is: is 3. possible ?
I can check recursively whether every member of a class has its fields private final, but this is not enough since a class can have e method named getHaha(param) which adds the given param to an array for instance.
So is there a good way to check if an object is immutable or is it even possible ?
Thanks,