Results 1 to 3 of 3
- 10-21-2011, 04:08 AM #1
Member
- Join Date
- Feb 2011
- Posts
- 24
- Rep Power
- 0
Class<T> implements Serializable? What are the Implications?
Hello fellow programmers. A thought occurred to me while i was doing some coding and I started to wonder: why does the class Class<T> implement the Serializable interface? At that point I started to wonder if a .class file is simply a serialized Class object. Would anyone care to venture an explanation for this? If Class is serializable, then doesn't it sort of defeat the purpose of only being able to create Class objects through the ClassLoader because one could simply write the class object to a .ser file and then deserialize the Class object when you want to use the class. This could be useful in allowing multiple Class objects to be in the same file instead of requiring a seperate .class file for each class's definition.
- 10-21-2011, 06:48 AM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,427
- Blog Entries
- 7
- Rep Power
- 17
Re: Class<T> implements Serializable? What are the Implications?
Implementing Serializable means that instantiations of the class that implements this interface are serializable; not the class itself.
kind regarrds,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 10-21-2011, 07:38 AM #3
Member
- Join Date
- Feb 2011
- Posts
- 24
- Rep Power
- 0
Re: Class<T> implements Serializable? What are the Implications?
I apologize. Maybe I didn't make myself as clear as i thought. I understand that the instantiations are what is serializable. however, is it not possible to use the instantiations of different classes' class objects to store multiple classes in the same file and then just deserialize them into a program? Also, is a .class file basically a serialized version of the corresponding Class instance?
Similar Threads
-
Creating a class that extends Activity and implements OnClickListener
By sehudson in forum AndroidReplies: 4Last Post: 01-17-2012, 12:39 AM -
ObjectInputStream and the Serializable class
By Junky in forum Advanced JavaReplies: 5Last Post: 08-15-2011, 01:46 PM -
I need to keep a whole file as a serializable class field
By urbanleg in forum New To JavaReplies: 1Last Post: 07-10-2011, 04:33 PM -
List<Serializable> help
By BobswYourUcle in forum New To JavaReplies: 4Last Post: 03-18-2011, 04:28 PM -
Adding 2 Implements to the class
By jboy in forum New To JavaReplies: 2Last Post: 10-23-2009, 05:19 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks