Why does ArrayList use transient storage?

It can be serialized; the ArrayList class just takes care of things itself, rather than using the default mechanism. Look at the writeObject() and readObject() methods in that class, which are part of the standard serialization mechanism. If you look at the source, you see that writeObject() does not save the backing array. Instead, it … Read more

Java static serialization rules?

statics are implicitly transient, so you don’t need to declare them as such. Serialization is for serializing instances, not classes. static fields (methods are irrelevant since they are part of the class definition so they aren’t serialized) will be reinitialized to whatever value they are set to when the class is loaded. If you have … Read more

Android Room: @Ignore vs Transient

@Ignore is a Room-specific annotation, saying that Room should ignore that field or method. transient is a Java construct, indicating that this field should not be serialized in standard Java serialization. Room happens to treat this similarly to @Ignore by default. Mostly, that is there for cases where you are inheriting from some class that … Read more

Why jackson is serializing transient member also?

The reason Jackson serializes the transient member is because the getters are used to determine what to serialize, not the member itself – and since y has a public getter, that gets serialized. If you want to change that default and have Jackson use fields – simply do: om.setVisibilityChecker( om.getSerializationConfig() .getDefaultVisibilityChecker() .withFieldVisibility(JsonAutoDetect.Visibility.ANY) .withGetterVisibility(JsonAutoDetect.Visibility.NONE) ); Another … Read more

Why does Java have transient fields?

The transient keyword in Java is used to indicate that a field should not be part of the serialization (which means saved, like to a file) process. From the Java Language Specification, Java SE 7 Edition, Section 8.3.1.3. transient Fields: Variables may be marked transient to indicate that they are not part of the persistent … Read more