1. /*
  2. * @(#)ServerCloneException.java 1.20 03/12/19
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.rmi.server;
  8. /**
  9. * A <code>ServerCloneException</code> is thrown if a remote exception occurs
  10. * during the cloning of a <code>UnicastRemoteObject</code>.
  11. *
  12. * <p>As of release 1.4, this exception has been retrofitted to conform to
  13. * the general purpose exception-chaining mechanism. The "nested exception"
  14. * that may be provided at construction time and accessed via the public
  15. * {@link #detail} field is now known as the <i>cause</i>, and may be
  16. * accessed via the {@link Throwable#getCause()} method, as well as
  17. * the aforementioned "legacy field."
  18. *
  19. * <p>Invoking the method {@link Throwable#initCause(Throwable)} on an
  20. * instance of <code>ServerCloneException</code> always throws {@link
  21. * IllegalStateException}.
  22. *
  23. * @version 1.20, 12/19/03
  24. * @author Ann Wollrath
  25. * @since JDK1.1
  26. * @see java.rmi.server.UnicastRemoteObject#clone()
  27. */
  28. public class ServerCloneException extends CloneNotSupportedException {
  29. /**
  30. * The cause of the exception.
  31. *
  32. * <p>This field predates the general-purpose exception chaining facility.
  33. * The {@link Throwable#getCause()} method is now the preferred means of
  34. * obtaining this information.
  35. *
  36. * @serial
  37. */
  38. public Exception detail;
  39. /* indicate compatibility with JDK 1.1.x version of class */
  40. private static final long serialVersionUID = 6617456357664815945L;
  41. /**
  42. * Constructs a <code>ServerCloneException</code> with the specified
  43. * detail message.
  44. *
  45. * @param s the detail message.
  46. */
  47. public ServerCloneException(String s) {
  48. super(s);
  49. initCause(null); // Disallow subsequent initCause
  50. }
  51. /**
  52. * Constructs a <code>ServerCloneException</code> with the specified
  53. * detail message and cause.
  54. *
  55. * @param s the detail message.
  56. * @param cause the cause
  57. */
  58. public ServerCloneException(String s, Exception cause) {
  59. super(s);
  60. initCause(null); // Disallow subsequent initCause
  61. detail = cause;
  62. }
  63. /**
  64. * Returns the detail message, including the message from the cause, if
  65. * any, of this exception.
  66. *
  67. * @return the detail message
  68. */
  69. public String getMessage() {
  70. if (detail == null)
  71. return super.getMessage();
  72. else
  73. return super.getMessage() +
  74. "; nested exception is: \n\t" +
  75. detail.toString();
  76. }
  77. /**
  78. * Returns the cause of this exception. This method returns the value
  79. * of the {@link #detail} field.
  80. *
  81. * @return the cause, which may be <tt>null</tt>.
  82. * @since 1.4
  83. */
  84. public Throwable getCause() {
  85. return detail;
  86. }
  87. }