Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4335276

LineEvent serialization does not work

XMLWordPrintable



      Name: ooR10001 Date: 05/03/2000



      javax.sound.sampled.LineEvent object could not be serialized,
      because it has non-transient and non-static field 'type' of
      non-Serializable class javax.sound.sampled.LineEvent.Type.
      It caused a problem.
       
      The test example to reproduce the bug:
      -------------------------------------------------------------
      import java.io.FileOutputStream;
      import java.io.ObjectOutputStream;
      import javax.sound.sampled.AudioSystem;

      public class test {

        public static void main(String[] args) {
          try {

              javax.sound.sampled.LineEvent obj =
                  new javax.sound.sampled.LineEvent(
                      AudioSystem.getLine(new javax.sound.sampled.Line$Info(
                      javax.sound.sampled.Line.class)),
                      javax.sound.sampled.LineEvent$Type.START, 0L);

              FileOutputStream ostream = new FileOutputStream("gold.tmp");
              ObjectOutputStream objos = new ObjectOutputStream(ostream);
              objos.writeObject(obj);
              objos.close();
              System.out.println("OKAY");

          } catch (java.io.IOException e) {
              e.printStackTrace();
          } catch (javax.sound.sampled.LineUnavailableException e) {
          }
        }

      }
      -------------------------------------------------------------
      Test output:

      java.io.NotSerializableException: javax.sound.sampled.LineEvent$Type
              at
      java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:1148)
              at
      java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:366)
              at
      java.io.ObjectOutputStream.outputClassFields(ObjectOutputStream.java:1841)
              at
      java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:480)
              at
      java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:1214)
              at
      java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:366)
              at test.main(test.java:18)
      <program hangs>
      -------------------------------------------------------------
      ======================================================================

            fbomerssunw Florian Bomers (Inactive)
            oovsunw Oov Oov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: