1. /*
  2. * @(#)InvalidClassException.java 1.19 03/01/23
  3. *
  4. * Copyright 2003 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.19, 01/23/03
  20. * @since JDK1.1
  21. */
  22. public class InvalidClassException extends ObjectStreamException {
  23. /**
  24. * Name of the invalid class.
  25. *
  26. * @serial Name of the invalid class.
  27. */
  28. public String classname;
  29. /**
  30. * Report a InvalidClassException for the reason specified.
  31. *
  32. * @param reason String describing the reason for the exception.
  33. */
  34. public InvalidClassException(String reason) {
  35. super(reason);
  36. }
  37. /**
  38. * Constructs an InvalidClassException object.
  39. *
  40. * @param cname a String naming the invalid class.
  41. * @param reason a String describing the reason for the exception.
  42. */
  43. public InvalidClassException(String cname, String reason) {
  44. super(reason);
  45. classname = cname;
  46. }
  47. /**
  48. * Produce the message and include the classname, if present.
  49. */
  50. public String getMessage() {
  51. if (classname == null)
  52. return super.getMessage();
  53. else
  54. return classname + "; " + super.getMessage();
  55. }
  56. }