Parcelable encountered IOException writing serializable object getactivity()

so I am getting this in logcat: java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = com.resources.student_list.Student) I know this means that my student class is not serializable, but it is, here is my student class: import java.io.Serializable; public class Student implements Comparable<Student>, Serializable{ private static final long serialVersionUID = 1L; private String firstName, lastName; … Read more

Why generate long serialVersionUID instead of a simple 1L?

When class implements Serializable in Eclipse, I have two options: add default serialVersionUID(1L) or generated serialVersionUID(3567653491060394677L). I think that first one is cooler, but many times I saw people using the second option. Is there any reason to generate long serialVersionUID? 11 Answers 11

Task not serializable: java.io.NotSerializableException when calling function outside closure only on classes not objects

Getting strange behavior when calling function outside of a closure: when function is in a object everything is working when function is in a class get : Task not serializable: java.io.NotSerializableException: testing The problem is I need my code in a class and not an object. Any idea why this is happening? Is a Scala … Read more

Convert string to Enum in Python

I wonder what’s the correct way of converting (deserializing) a string to a Python’s Enum class. Seems like getattr(YourEnumType, str) does the job, but I’m not sure if it’s safe enough. Just to be more specific, I would like to convert a ‘debug’string to an Enum object like this: class BuildType(Enum): debug = 200 release … Read more

Django rest framework, use different serializers in the same ModelViewSet

I would like to provide two different serializers and yet be able to benefit from all the facilities of ModelViewSet: When viewing a list of objects, I would like each object to have an url which redirects to its details and every other relation appear using __unicode __ of the target model; example: { “url”: … Read more

What is the correct way to make a custom .NET Exception serializable?

More specifically, when the exception contains custom objects which may or may not themselves be serializable. Take this example: public class MyException : Exception { private readonly string resourceName; private readonly IList<string> validationErrors; public MyException(string resourceName, IList<string> validationErrors) { this.resourceName = resourceName; this.validationErrors = validationErrors; } public string ResourceName { get { return this.resourceName; } … Read more