1 |
/* |
/* ServerCloneException.java -- a UnicastRemoteObject could not be cloned |
2 |
Copyright (c) 1996, 1997, 1998, 1999 Free Software Foundation, Inc. |
Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc. |
3 |
|
|
4 |
This file is part of GNU Classpath. |
This file is part of GNU Classpath. |
5 |
|
|
7 |
it under the terms of the GNU General Public License as published by |
it under the terms of the GNU General Public License as published by |
8 |
the Free Software Foundation; either version 2, or (at your option) |
the Free Software Foundation; either version 2, or (at your option) |
9 |
any later version. |
any later version. |
10 |
|
|
11 |
GNU Classpath is distributed in the hope that it will be useful, but |
GNU Classpath is distributed in the hope that it will be useful, but |
12 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
37 |
|
|
38 |
package java.rmi.server; |
package java.rmi.server; |
39 |
|
|
40 |
import java.lang.CloneNotSupportedException; |
/** |
41 |
import java.io.PrintStream; |
* Thrown if a remote exception occurs during the cloning process of a |
42 |
import java.io.PrintWriter; |
* <code>UnicastRemoteObject</code>. |
43 |
|
* |
44 |
public class ServerCloneException |
* @author unknown |
45 |
extends CloneNotSupportedException { |
* @see UnicastRemoteObject#clone() |
46 |
|
* @since 1.1 |
47 |
public Exception detail; |
* @status updated to 1.4 |
48 |
|
*/ |
49 |
public ServerCloneException(String s) { |
public class ServerCloneException extends CloneNotSupportedException |
50 |
super(s); |
{ |
51 |
detail = null; |
/** |
52 |
} |
* Compatible with JDK 1.1+. |
53 |
|
*/ |
54 |
public ServerCloneException(String s, Exception e) { |
private static final long serialVersionUID = 6617456357664815945L; |
55 |
super(s); |
|
56 |
detail = e; |
/** |
57 |
} |
* The cause of this exception. This pre-dates the exception chaining |
58 |
|
* of Throwable; and although you can change this field, you are wiser |
59 |
public String getMessage() { |
* to leave it alone. |
60 |
if (detail != null) { |
* |
61 |
return (super.getMessage() + ":" + detail.getMessage()); |
* @serial the exception cause |
62 |
} |
*/ |
63 |
else { |
public Exception detail; |
64 |
return (super.getMessage()); |
|
65 |
} |
/** |
66 |
} |
* Create an exception with a message. |
67 |
|
* |
68 |
public void printStackTrace(PrintStream s) { |
* @param s the message |
69 |
if (detail != null) { |
*/ |
70 |
detail.printStackTrace(s); |
public ServerCloneException(String s) |
71 |
} |
{ |
72 |
super.printStackTrace(s); |
this(s, null); |
73 |
} |
} |
74 |
|
|
75 |
public void printStackTrace() { |
/** |
76 |
printStackTrace(System.err); |
* Create an exception with a message and a cause. |
77 |
} |
* |
78 |
|
* @param s the message |
79 |
public void printStackTrace(PrintWriter s) { |
* @param e the cause |
80 |
if (detail != null) { |
*/ |
81 |
detail.printStackTrace(s); |
public ServerCloneException(String s, Exception e) |
82 |
} |
{ |
83 |
super.printStackTrace(s); |
super(s); |
84 |
} |
initCause(e); |
85 |
|
detail = e; |
86 |
|
} |
87 |
|
|
88 |
|
/** |
89 |
|
* This method returns a message indicating what went wrong, in this |
90 |
|
* format: |
91 |
|
* <code>super.getMessage() + (detail == null ? "" |
92 |
|
* : "; nested exception is:\n\t" + detail)<code>. |
93 |
|
* |
94 |
|
* @return the chained message |
95 |
|
*/ |
96 |
|
public String getMessage() |
97 |
|
{ |
98 |
|
if (detail == this || detail == null) |
99 |
|
return super.getMessage(); |
100 |
|
return super.getMessage() + "; nested exception is:\n\t" + detail; |
101 |
|
} |
102 |
|
|
103 |
|
/** |
104 |
|
* Returns the cause of this exception. Note that this may not be the |
105 |
|
* original cause, thanks to the <code>detail</code> field being public |
106 |
|
* and non-final (yuck). However, to avoid violating the contract of |
107 |
|
* Throwable.getCause(), this returns null if <code>detail == this</code>, |
108 |
|
* as no exception can be its own cause. |
109 |
|
* |
110 |
|
* @return the cause |
111 |
|
* @since 1.4 |
112 |
|
*/ |
113 |
|
public Throwable getCause() |
114 |
|
{ |
115 |
|
return detail == this ? null : detail; |
116 |
|
} |
117 |
} |
} |