Is there any way to check whether an object is serializable or not in java?

Jaykishan

I found that Object class in java is not serializable in java at the end when i've wasted much time for a problem.
So can anybody knows another class's those are not serializable or any way to check whether that class is serializable?

René Link

Use

if(someObj instanceof Serializable) // recommended because it uses 
                                    // the byte code instruction INSTANCEOF

or

if(Serializable.class.isInstance(someObj))

Using Class.isInstance(someObj) makes sense if the Class should be replaceable at runtime.

For example:

Class<?> someClass == ....; // assign a class object reference dynamically
if(someClass.isInstance(someObj))

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Is there any way to check whether a localised string is a valid number in Java?

Is there a way to check whether a related object is already fetched?

Is there a way to check whether a stream is finite in Java?

Check whether a Java Object has been modified

Is there any way to check whether a function has been declared?

Is there a way to check whether there is any type of file extension included?

Is there any way to check whether the class has attribute in PHP?

Is there any way to check whether there is an incoming message in Python Socket

Check whether there are any updates

Check whether an Object contains a specific value in any of its array

Correct way to check if any object is a SyntheticEvent?

Is there any way to check if an object is a type of enum in TypeScript?

In scala, is there any way to check if an instance is a singleton object or not?

How to check whether the process results any error or not in Java?

Clone Serializable Object - JAVA

Is there any way, in java, to check on the status of a windows service?

Any way to check an object if its breeze entity object?

cleaner way to check whether or not a the current window.location.href is equal to any of the strings in the array

Is there any way to check whether input n is less than or equal to length of list?

is doing (ptr && *ptr) good way to check whether any value assigned to the ptr? mine just keep crashing

Python 2.7.10 :Is there any other way to check whether an input is empty other than using len()

Is there any way to check programmatically whether SAS URL for Azure blob storage expired or not?

Reliable way to check if objects is serializable in JavaScript

Is there any way to check if there is a null value in an object or array? mocha - chai

Is there a way to check if any existing object contains a specific string paramater?

Is there any safe way to check the deep of object's property?

java - fastest way to check if object is null

Is there a way to check if object is List or List of Lists in Java

Is there a way to check if java object changed after submit