1. /*
  2. * @(#)InvalidClassException.java 1.14 01/11/29
  3. *
  4. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.io;
  8. /**
  9. * Thrown when the Serialization runtime detects one of the following
  10. * problems with a Class.
  11. * <UL>
  12. * <LI> The serial version of the class does not match that of the class
  13. * descriptor read from the stream
  14. * <LI> The class contains unknown datatypes
  15. * <LI> The class does not have an accessible no-arg constructor
  16. * </UL>
  17. *
  18. * @author unascribed
  19. * @version 1.14, 11/29/01
  20. * @since JDK1.1
  21. */
  22. public class InvalidClassException extends ObjectStreamException {
  23. /**
  24. * @serial Name of the invalid class.
  25. */
  26. public String classname;
  27. /**
  28. * Report a InvalidClassException for the reason specified.
  29. */
  30. public InvalidClassException(String reason) {
  31. super(reason);
  32. }
  33. /**
  34. */
  35. public InvalidClassException(String cname, String reason) {
  36. super(reason);
  37. classname = cname;
  38. }
  39. /**
  40. * Produce the message and include the classname, if present.
  41. */
  42. public String getMessage() {
  43. if (classname == null)
  44. return super.getMessage();
  45. else
  46. return classname + "; " + super.getMessage();
  47. }
  48. }