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

java.io.NotSerializableException is displayed by using jdk1.3.1 on WindowsNT4.0

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • 1.3.1
    • client-libs
    • Cause Known
    • x86
    • windows_nt

      Hitachi encountered this problem when they tried to shift their products from 1.3.0_0X to 1.3.1.
      This problem doesn't reproduce on 1.3.0_0x older and other OS(Only windows).
      Messages is following:
      ---------------
      D:\Hitachi\IO>java -version
      java version "1.3.1"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
      Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)

      D:\Hitachi\IO>java copy
      set data to clipboard
      java.io.NotSerializableException: my
              at java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:1148)

              at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:366)
              at java.io.ObjectOutputStream.outputArray(ObjectOutputStream.java:1098)
              at java.io.ObjectOutputStream.checkSubstitutableSpecialClasses(ObjectOutputStream.java:456)
              at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:361)
              at sun.awt.windows.WDataTransferer.translateTransferable(WDataTransferer.java:424)
              at sun.awt.DataTransferer.translateTransferable(DataTransferer.java:245)

              at sun.awt.windows.WClipboard.setContents(WClipboard.java:69)
              at data.initialize(copy.java:45)
              at data.<init>(copy.java:36)
              at copy.main(copy.java:13)
      set data to clipboard OK!!

      D:\Hitachi\IO>
      ---------------


      Test program is following:
      ---------------
      import java.awt.*;
      import java.awt.datatransfer.*;
      import java.awt.event.*;
      import java.lang.reflect.*;
      import java.io.*;
      import javax.swing.*;
      import javax.swing.event.*;

      class copy{
          public static void main(String args[]){
      try{
      System.out.println("set data to clipboard");
      new data(new my(), null);
      System.out.println("set data to clipboard OK!!");
      System.exit(0);
      }catch(Throwable t){
      t.printStackTrace();
      System.exit(1);
      }
          }
      }

      class data implements ClipboardOwner, Transferable{
          private Object source = null;
          private DataFlavor flavor = null;
          private ChangeListener change = null;
          private boolean invalid = false;

          static DataFlavor getFlavor(Class d){
      return new DataFlavor(d, d.getName());
          }

          data(Object o, ChangeListener l){
      Object[] array = (Object[])Array.newInstance(o.getClass(), 1);
      array[0] = o;
      initialize(l, array, getFlavor(array.getClass()));
          }

          private void initialize(ChangeListener l, Object[] o, DataFlavor f){
      change = l;
      source = o;
      flavor = f;

      Clipboard clip = Toolkit.getDefaultToolkit().getSystemClipboard();
      clip.setContents(this, this);
      invalid = false;
          }

          public void lostOwnership(Clipboard clipboard, Transferable contents){
      invalid = true;
      if (change != null)
      change.stateChanged(new ChangeEvent(this));
          }

          public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException{
      if (invalid){
      return null;
      }else if (this.flavor.equals(flavor)){
      return source;
      }
      throw new UnsupportedFlavorException(flavor);
          }

          public boolean isDataFlavorSupported(DataFlavor flavor){
              return !invalid && this.flavor.equals(flavor);
          }

          public DataFlavor[] getTransferDataFlavors(){
              return new DataFlavor[]{ flavor };
          }
      }

      class my{
          private String a = "aaa";
      }
      -------------------------------

            denis Denis Fokin (Inactive)
            mkamito Masaaki Kamito (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: