final transient fields and serialization
问题 Is it possible to have final transient fields that are set to any non-default value after serialization in Java? My usecase is a cache variable — that's why it is transient . I also have a habit of making Map fields that won't be changed (i.e. contents of the map is changed, but object itself remains the same) final . However, these attributes seem to be contradictory — while compiler allows such a combination, I cannot have the field set to anything but null after unserialization. I tried