Results 1 to 4 of 4
  1. #1
    xiang is offline Member
    Join Date
    Apr 2011
    Posts
    2
    Rep Power
    0

    Unhappy Serializing a class

    Hi experts, I have a question regarding serializing a java class (not object). I know Class implements the Serializable interface. I encountered a problem when deserializing a Class. The error basically says "failed to build body from bytes. Reason: java.io.IOException: some class name". What's the possible problem? Of cause, when deserializing, the class definition was not preloaded on the classpath... that's why I need to serialize the Class definition and send it a remote server.

    Thanks!!!

  2. #2
    ra4king's Avatar
    ra4king is offline Senior Member
    Join Date
    Apr 2011
    Location
    Atlanta, Georgia, US
    Posts
    396
    Rep Power
    4

    Default

    Yes but because Class is a generic class that points to the real class, it needs to have a copy of the real class that it represents to be able to be rebuilt.

  3. #3
    xiang is offline Member
    Join Date
    Apr 2011
    Posts
    2
    Rep Power
    0

    Default

    Quote Originally Posted by ra4king View Post
    Yes but because Class is a generic class that points to the real class, it needs to have a copy of the real class that it represents to be able to be rebuilt.
    If the remote server needs a copy of the real class, then what's the point of serializing a class? Is there a way to go around this? I need to serializing code that doesn't exist on a remote machine. Thanks!!

  4. #4
    ra4king's Avatar
    ra4king is offline Senior Member
    Join Date
    Apr 2011
    Location
    Atlanta, Georgia, US
    Posts
    396
    Rep Power
    4

    Default

    Serialization is used to preserve the instance variable values. If you want to send a .class file to another location, you are going to have to looking ClassLoader and other classes to be able to load this class into the runtime.

Similar Threads

  1. Serializing
    By shashanksworld in forum New To Java
    Replies: 7
    Last Post: 03-29-2010, 05:47 PM
  2. serializing pdf files
    By windie in forum New To Java
    Replies: 0
    Last Post: 03-11-2009, 05:46 PM
  3. Object not serializing
    By MamboBanda in forum New To Java
    Replies: 1
    Last Post: 08-12-2008, 01:15 AM
  4. Serializing Arrays
    By javaplus in forum New To Java
    Replies: 3
    Last Post: 11-08-2007, 10:09 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
  •