1/**
2 * Copyright 2006-2013 the original author or authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.objenesis;
17
18/**
19 * Exception thrown by Objenesis. It wraps any instantiation exceptions. Note that this exception is
20 * runtime to prevent having to catch it. It will do normal exception wrapping for JDK 1.4 and more
21 * and basic message wrapping for JDK 1.3.
22 *
23 * @author Henri Tremblay
24 */
25public class ObjenesisException extends RuntimeException {
26
27   private static final long serialVersionUID = -2677230016262426968L;
28
29   private static final boolean jdk14 = (Double.parseDouble(System
30      .getProperty("java.specification.version")) > 1.3);
31
32   /**
33    * @param msg Error message
34    */
35   public ObjenesisException(String msg) {
36      super(msg);
37   }
38
39   /**
40    * @param cause Wrapped exception. The message will be the one of the cause.
41    */
42   public ObjenesisException(Throwable cause) {
43      super(cause == null ? null : cause.toString());
44      if(jdk14) {
45         initCause(cause);
46      }
47   }
48
49   /**
50    * @param msg Error message
51    * @param cause Wrapped exception
52    */
53   public ObjenesisException(String msg, Throwable cause) {
54      super(msg);
55      if(jdk14) {
56         initCause(cause);
57      }
58   }
59}
60