1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * 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 * {@code RuntimeException} is the superclass of all classes that represent 22 * exceptional conditions which occur as a result of executing an application in 23 * the VM. Unlike checked exceptions (exceptions where the type 24 * doesn't extend {@code RuntimeException} or {@link Error}), the compiler does 25 * not require code to handle runtime exceptions. 26 */ 27 public class RuntimeException extends Exception { 28 29 private static final long serialVersionUID = -7034897190745766939L; 30 31 /** 32 * Constructs a new {@code RuntimeException} that includes the current stack 33 * trace. 34 */ RuntimeException()35 public RuntimeException() { 36 } 37 38 /** 39 * Constructs a new {@code RuntimeException} with the current stack trace 40 * and the specified detail message. 41 * 42 * @param detailMessage 43 * the detail message for this exception. 44 */ RuntimeException(String detailMessage)45 public RuntimeException(String detailMessage) { 46 super(detailMessage); 47 } 48 49 /** 50 * Constructs a new {@code RuntimeException} with the current stack trace, 51 * the specified detail message and the specified cause. 52 * 53 * @param detailMessage 54 * the detail message for this exception. 55 * @param throwable 56 * the cause of this exception. 57 */ RuntimeException(String detailMessage, Throwable throwable)58 public RuntimeException(String detailMessage, Throwable throwable) { 59 super(detailMessage, throwable); 60 } 61 62 /** 63 * Constructs a new {@code RuntimeException} with the current stack trace 64 * and the specified cause. 65 * 66 * @param throwable 67 * the cause of this exception. 68 */ RuntimeException(Throwable throwable)69 public RuntimeException(Throwable throwable) { 70 super(throwable); 71 } 72 } 73