Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-1627

Deserialization fails to work

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      Ubuntu 6.10 Edgy Eft + Groovy r4630

      Description

      Serialization appears to work fine but deserialization fails to work at all.

      The script;

      import java.io.FileInputStream
      import java.io.FileOutputStream
      import java.io.ObjectInputStream
      import java.io.ObjectOutputStream
      import java.io.Serializable
      
      class Blah implements Serializable {
        def x
        def y
        public Blah ( x , y ) {
          this.x = x
          this.y = y
        }
      }
      
      def fileName = 'thingy.txt'
      def data = [ new Blah ( 1 , 2 ) , new Blah ( 'flob' , 'adob' ) ]
      def file = new ObjectOutputStream ( new FileOutputStream ( fileName ) )
      file.writeObject ( data )
      file.close ( )
      file = new ObjectInputStream ( new FileInputStream ( fileName ) )
      def newData = file.readObject ( ) // ClassNotFoundException here.
      assert data == newData
      

      results in the output:

      Caught: java.lang.ClassNotFoundException: Blah
      at serialization.run(serialization.groovy:22)
      at serialization.main(serialization.groovy)

        Attachments

          Activity

            People

            • Assignee:
              paulk Paul King
              Reporter:
              russel Dr. Russel Winder
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: