1/* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements.  See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License.  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 */
16
17package java.lang;
18
19/**
20 * Thrown when a program tries to access a class, interface, enum or annotation
21 * type through a string that contains the type's name and the type cannot be
22 * found. This exception is an unchecked alternative to
23 * {@link java.lang.ClassNotFoundException}.
24 *
25 * @since 1.5
26 */
27public class TypeNotPresentException extends RuntimeException {
28    private static final long serialVersionUID = -5101214195716534496L;
29
30    private String typeName;
31
32    /**
33     * Constructs a new {@code TypeNotPresentException} with the current stack
34     * trace, a detail message that includes the name of the type that could not
35     * be found and the {@code Throwable} that caused this exception.
36     *
37     * @param typeName
38     *            the fully qualified name of the type that could not be found.
39     * @param cause
40     *            the optional cause of this exception, may be {@code null}.
41     */
42    public TypeNotPresentException(String typeName, Throwable cause) {
43        super("Type " + typeName + " not present", cause);
44        this.typeName = typeName;
45    }
46
47    /**
48     * Gets the fully qualified name of the type that could not be found.
49     *
50     * @return the name of the type that caused this exception.
51     */
52    public String typeName() {
53        return typeName;
54    }
55}
56