?
Solved

Java exceptions cannot be serialized or can they?

Posted on 2011-05-02
8
Medium Priority
?
289 Views
Last Modified: 2012-05-11
Java exceptions cannot be serialized (or can they?) so why does Eclipse suggest that a class I have created that extends Exception should have serialVersionUID field added to it?
0
Comment
Question by:robocop100
  • 4
  • 2
7 Comments
 
LVL 47

Accepted Solution

by:
for_yan earned 200 total points
ID: 35505839
class Exception implements Serilaizable

So why can't it be serialized?

See:
http://download.oracle.com/javase/6/docs/api/java/lang/Exception.html
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 35505846
That's nothing to do with exceptions: it's to do with the binary integrity of the class:

http://mindprod.com/jgloss/serialization.html#SERIALVERSIONUID
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 35506259
robocop100, can you explain why you accepted that answer?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:robocop100
ID: 35506284
My question is based on the thought that Exceptions cannot be serialized.

for_yan responded:
"class Exception implements Serilaizable"

Therefore Exceptions CAN be serialized.


0
 
LVL 86

Expert Comment

by:CEHJ
ID: 35506303
... and i answered

>>so why does Eclipse suggest that a class I have created that extends Exception should have serialVersionUID field added to it?

which you ignored..?
0
 

Author Comment

by:robocop100
ID: 35506332
The premise was false!!! Don't you get it!!

It makes perfect sense to add serialVersionUID to classes that CAN be serialized. I understand that!!!!

I thought that exceptions could not be serialized.

All you had to explain was that Exceptions CAN be serialized. for_yan did precisely that.

You need to read questions more carefully to ensure that you understand what is being asked.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 35506423
Excuse me - YOU need to refrain from asking questions (again below)

>>so why does Eclipse suggest that a class I have created that extends Exception should have serialVersionUID field added to it?

if you're not interested in the answers - it's just wasting people's time
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses
Course of the Month14 days, 8 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question