01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package java.lang;
19:
20: /**
21: * This error is thrown when an exception occurs during class initialization.
22: */
23: public class ExceptionInInitializerError extends LinkageError {
24:
25: private static final long serialVersionUID = 1521711792217232256L;
26:
27: private Throwable exception;
28:
29: /**
30: * Constructs a new instance of this class with its walkback filled in.
31: */
32: public ExceptionInInitializerError() {
33: super ();
34: initCause(null);
35: }
36:
37: /**
38: * Constructs a new instance of this class with its walkback and message
39: * filled in.
40: *
41: * @param detailMessage
42: * String The detail message for the exception.
43: */
44: public ExceptionInInitializerError(String detailMessage) {
45: super (detailMessage);
46: initCause(null);
47: }
48:
49: /**
50: * Constructs a new instance of this class with its walkback and exception
51: * filled in. The exception should be the one which originally occurred in
52: * the class initialization code.
53: *
54: * @param exception
55: * Throwable The exception which caused the problem.
56: */
57: public ExceptionInInitializerError(Throwable exception) {
58: super ();
59: this .exception = exception;
60: initCause(exception);
61: }
62:
63: /**
64: * Answers the exception which was passed in when the instance was created.
65: */
66: public Throwable getException() {
67: return exception;
68: }
69:
70: /**
71: * Answers the cause of this Throwable, or null if there is no cause.
72: *
73: * @return Throwable The receiver's cause.
74: */
75: @Override
76: public Throwable getCause() {
77: return exception;
78: }
79: }
|