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 virtual machine. 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 super(); 37 } 38 39 /** 40 * Constructs a new {@code RuntimeException} with the current stack trace 41 * and the specified detail message. 42 * 43 * @param detailMessage 44 * the detail message for this exception. 45 */ RuntimeException(String detailMessage)46 public RuntimeException(String detailMessage) { 47 super(detailMessage); 48 } 49 50 /** 51 * Constructs a new {@code RuntimeException} with the current stack trace, 52 * the specified detail message and the specified cause. 53 * 54 * @param detailMessage 55 * the detail message for this exception. 56 * @param throwable 57 * the cause of this exception. 58 */ RuntimeException(String detailMessage, Throwable throwable)59 public RuntimeException(String detailMessage, Throwable throwable) { 60 super(detailMessage, throwable); 61 } 62 63 /** 64 * Constructs a new {@code RuntimeException} with the current stack trace 65 * and the specified cause. 66 * 67 * @param throwable 68 * the cause of this exception. 69 */ RuntimeException(Throwable throwable)70 public RuntimeException(Throwable throwable) { 71 super(throwable); 72 } 73 } 74