1. /*
  2. * @(#)InvalidClassException.java 1.17 00/02/02
  3. *
  4. * Copyright 1996-2000 Sun Microsystems, Inc. All Rights Reserved.
  5. *
  6. * This software is the proprietary information of Sun Microsystems, Inc.
  7. * Use is subject to license terms.
  8. *
  9. */
  10. package java.io;
  11. /**
  12. * Thrown when the Serialization runtime detects one of the following
  13. * problems with a Class.
  14. * <UL>
  15. * <LI> The serial version of the class does not match that of the class
  16. * descriptor read from the stream
  17. * <LI> The class contains unknown datatypes
  18. * <LI> The class does not have an accessible no-arg constructor
  19. * </UL>
  20. *
  21. * @author unascribed
  22. * @version 1.17, 02/02/00
  23. * @since JDK1.1
  24. */
  25. public class InvalidClassException extends ObjectStreamException {
  26. /**
  27. * Name of the invalid class.
  28. *
  29. * @serial Name of the invalid class.
  30. */
  31. public String classname;
  32. /**
  33. * Report a InvalidClassException for the reason specified.
  34. *
  35. * @param reason String describing the reason for the exception.
  36. */
  37. public InvalidClassException(String reason) {
  38. super(reason);
  39. }
  40. /**
  41. * Constructs an InvalidClassException object.
  42. *
  43. * @param cname a String naming the invalid class.
  44. * @param reason a String describing the reason for the exception.
  45. */
  46. public InvalidClassException(String cname, String reason) {
  47. super(reason);
  48. classname = cname;
  49. }
  50. /**
  51. * Produce the message and include the classname, if present.
  52. */
  53. public String getMessage() {
  54. if (classname == null)
  55. return super.getMessage();
  56. else
  57. return classname + "; " + super.getMessage();
  58. }
  59. }