fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. class Ideone
  8. {
  9. static class Test implements Externalizable
  10. {
  11. // public Test() {}
  12.  
  13. public Test(int x)
  14. {
  15. }
  16.  
  17. public void writeExternal(ObjectOutput out) throws IOException
  18. {
  19. }
  20.  
  21. public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
  22. {
  23. }
  24. }
  25.  
  26. public static void main (String[] args) throws java.lang.Exception
  27. {
  28. Test t = new Test(0);
  29. oos.writeObject(t);
  30. oos.close();
  31.  
  32. ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray());
  33. t = (Test) ois.readObject();
  34. ois.close();
  35. }
  36. }
Runtime error #stdin #stdout #stderr 0.1s 380480KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Exception in thread "main" java.io.InvalidClassException: Ideone$Test; no valid constructor
	at java.io.ObjectStreamClass$ExceptionInfo.newInvalidClassException(ObjectStreamClass.java:147)
	at java.io.ObjectStreamClass.checkDeserialize(ObjectStreamClass.java:755)
	at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1751)
	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
	at java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)
	at Ideone.main(Main.java:36)