Results 1 to 3 of 3
  1. #1
    kennyman94 is offline Member
    Join Date
    Feb 2011
    Posts
    24
    Rep Power
    0

    Default 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.

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,372
    Blog Entries
    7
    Rep Power
    20

    Default 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,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    kennyman94 is offline Member
    Join Date
    Feb 2011
    Posts
    24
    Rep Power
    0

    Default 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

  1. Replies: 4
    Last Post: 01-17-2012, 12:39 AM
  2. ObjectInputStream and the Serializable class
    By Junky in forum Advanced Java
    Replies: 5
    Last Post: 08-15-2011, 01:46 PM
  3. Replies: 1
    Last Post: 07-10-2011, 04:33 PM
  4. List<Serializable> help
    By BobswYourUcle in forum New To Java
    Replies: 4
    Last Post: 03-18-2011, 04:28 PM
  5. Adding 2 Implements to the class
    By jboy in forum New To Java
    Replies: 2
    Last Post: 10-23-2009, 05:19 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •