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

Failure to find int.class on de-serialization

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P5 P5
    • None
    • 1.1.3
    • core-libs
    • None

      The following code throws a "ClassNotFoundException: int" exception:

      import java.io.*;
      public class Primtest extends Object {

        /** Creates new Primtest */
        public Primtest() {
        }
        
        /**
        * @param args the command line arguments
        */
        public static void main (String args[]) {
            try {
              ByteArrayOutputStream o = new ByteArrayOutputStream();
              ObjectOutputStream oos = new ObjectOutputStream(o);
              Class c = int.class;
              oos.writeObject(c);
              oos.close();
              o.close();
              ByteArrayInputStream i = new ByteArrayInputStream(o.toByteArray());
              ObjectInputStream ois = new ObjectInputStream(i);
              c = (Class)ois.readObject();
            } catch (Exception e){
              e.printStackTrace();
            }
        }

      }

            nsanjeevsunw Naveen Sanjeeva (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: