1. /*
  2. * @(#)ServerCloneException.java 1.18 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.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. * @version 1.18, 01/23/03
  20. * @author Ann Wollrath
  21. * @since JDK1.1
  22. * @see java.rmi.server.UnicastRemoteObject#clone()
  23. */
  24. public class ServerCloneException extends CloneNotSupportedException {
  25. /**
  26. * Nested exception for ServerCloneException.
  27. *
  28. * <p>This field predates the general-purpose exception chaining facility.
  29. * The {@link Throwable#getCause()} method is now the preferred means of
  30. * obtaining this information.
  31. *
  32. * @serial
  33. * @since JDK1.1
  34. */
  35. public Exception detail;
  36. /* indicate compatibility with JDK 1.1.x version of class */
  37. private static final long serialVersionUID = 6617456357664815945L;
  38. /**
  39. * Constructs an <code>ServerCloneException</code> with the specified
  40. * detail message.
  41. *
  42. * @param s the detail message.
  43. * @since JDK1.1
  44. */
  45. public ServerCloneException(String s) {
  46. super(s);
  47. initCause(null); // Disallow subsequent initCause
  48. }
  49. /**
  50. * Constructs an <code>ServerCloneException</code> with the specified
  51. * detail message and nested exception.
  52. *
  53. * @param s the detail message.
  54. * @param ex the nested exception
  55. * @since JDK1.1
  56. */
  57. public ServerCloneException(String s, Exception ex) {
  58. super(s);
  59. initCause(null); // Disallow subsequent initCause
  60. detail = ex;
  61. }
  62. /**
  63. * Returns the detail message, including the message from the nested
  64. * exception if there is one.
  65. *
  66. * @return the detail message, including nested exception message if any
  67. */
  68. public String getMessage() {
  69. if (detail == null)
  70. return super.getMessage();
  71. else
  72. return super.getMessage() +
  73. "; nested exception is: \n\t" +
  74. detail.toString();
  75. }
  76. /**
  77. * Returns the nested exception (the <i>cause</i>).
  78. *
  79. * @return the nested exception, which may be <tt>null</tt>.
  80. * @since 1.4
  81. */
  82. public Throwable getCause() {
  83. return detail;
  84. }
  85. }