Sunday, 15 May 2011

java - Array of non-serializable objects is serilzable? -



java - Array of non-serializable objects is serilzable? -

to best of knowledge "com.google.api.services.drive.model.file" not serilizable. when here doesn't implement serilizable, , when seek set intent serilizable (as shown below) compiler error preventing me.

yet if wrap these non-serilizable files array, no compiler warning when write intent serilizable. thought must certainly result in run time error though -- perhaps compiler cant see i'm holding non-serilizable objects in array.

curiosity got improve of me , ran test, , surprise worked. broadcast intent array of files component parts, , retrieved info them.

so can explain me why working is?

intent intent = new intent(); string key = "key"; //com.google.api.services.drive.model.file not serializable (i think) com.google.api.services.drive.model.file file = new file(); com.google.api.services.drive.model.file[] files = new file[]{}; intent.putextra(key, files); // yet serializing array of files, no compiler error intent.putextra(key, file); // putting 1 file, compiler error.

edit: understand wrapping un-serialized file making java inspect serializable, happens if class has private fields? file have private fields (albeit lots of public get/sets)..., how serialize recording private fields -- isn't suppose withheld? in other words, there risk of info loss fields beingness private, or class handing on serialization process now?

serializable marker interface tell compiler want object able serialized. since arrays serializable, contents serialized.

java android serialization

No comments:

Post a Comment