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

Deserialization fails to work

Agile BoardAttach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • None
    • None
    • None
    • 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

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

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

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment