Path: blob/master/jcl/src/java.base/share/classes/java/lang/ClassCastException.java
12513 views
/*[INCLUDE-IF Sidecar16]*/12package java.lang;34/*******************************************************************************5* Copyright (c) 1998, 2017 IBM Corp. and others6*7* This program and the accompanying materials are made available under8* the terms of the Eclipse Public License 2.0 which accompanies this9* distribution and is available at https://www.eclipse.org/legal/epl-2.0/10* or the Apache License, Version 2.0 which accompanies this distribution and11* is available at https://www.apache.org/licenses/LICENSE-2.0.12*13* This Source Code may also be made available under the following14* Secondary Licenses when the conditions for such availability set15* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU16* General Public License, version 2 with the GNU Classpath17* Exception [1] and GNU General Public License, version 2 with the18* OpenJDK Assembly Exception [2].19*20* [1] https://www.gnu.org/software/classpath/license.html21* [2] http://openjdk.java.net/legal/assembly-exception.html22*23* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception24*******************************************************************************/2526/**27* This runtime exception is thrown when a program attempts to cast an object28* to a type with which it is not compatible.29*30* @version initial31*/32public class ClassCastException extends RuntimeException {33private static final long serialVersionUID = -9223365651070458532L;3435/**36* Constructs a new instance of this class with its walkback filled in.37*38* @version initial39*/40public ClassCastException() {41super();42}4344/**45* Constructs a new instance of this class with its walkback and message46* filled in.47*48* @version initial49*50* @param detailMessage51* String The detail message for the exception.52*/53public ClassCastException(String detailMessage) {54super(detailMessage);55}5657/**58* Constructs a new instance of this class with its walkback and message59* filled in.60*61* @version initial62*63* @param instanceClass64* Class The class being cast from.65*66* @param castClass67* Class The class being cast to.68*/69ClassCastException(Class instanceClass, Class castClass) {70/*[MSG "K0340", "{0} incompatible with {1}"]*/71super(com.ibm.oti.util.Msg.getString("K0340", instanceClass.getName(), castClass.getName())); //$NON-NLS-1$72}7374}757677