Adding ParameterizedTypeImpl to getGenericSuperclass method.
[jpf-core.git] / src / main / gov / nasa / jpf / vm / ClassInfoException.java
1 /*
2  * Copyright (C) 2014, United States Government, as represented by the
3  * Administrator of the National Aeronautics and Space Administration.
4  * All rights reserved.
5  *
6  * The Java Pathfinder core (jpf-core) platform is licensed under the
7  * Apache License, Version 2.0 (the "License"); you may not use this file except
8  * in compliance with the License. You may obtain a copy of the License at
9  * 
10  *        http://www.apache.org/licenses/LICENSE-2.0. 
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and 
16  * limitations under the License.
17  */
18 package gov.nasa.jpf.vm;
19
20 /**
21  * @author Nastaran Shafiei <nastaran.shafiei@gmail.com>
22  *
23  * This unchecked exception is thrown by the host VM. It captures all errors
24  * and exceptions that can occur at the load of a JPF class, which includes 
25  * defining, and resolving it. Here are some of the scenarios that this 
26  * exception is thrown and captures the corresponding exception:
27  *
28  *    * if the representation does not represent a class with the requested 
29  *      name, loading throws an instance of NoClassDefFoundError
30  *
31  *    * if any of the superclasses of a class, is the class itself, or if 
32  *      any of the superinterfaces of an interface, is the interface itself, 
33  *      loading throws an instance of ClassCircularityError
34  *
35  *    * if the representation is not a ClassFile structure, loading throws an
36  *      instance of ClassFormatError
37  * 
38  * If this exception is thrown during the initialization of VM, and the failed
39  * class is a system class, or creating of the main thread in not successful, we 
40  * immediately bail out by throwing JPFException.
41  * 
42  * While JPF is running, this error is handled by throwing an exception at the 
43  * SUT level. This exception is handled if it is thrown by 
44  * 
45  *    1. a native peer method,  
46  *    2. Intruction.execute(),
47  *    3. ThreadInfo.creatAndThrowException()
48  *    4. VM.initialize() // here it is handled only if it a non-system class
49  * 
50  * If this exception is thrown by a Listener, the host VM throws JPFListenerException.
51  * 
52  */
53 public class ClassInfoException extends RuntimeException{
54
55   ClassLoaderInfo classLoader;
56   String exceptionClass; // how we map this into the SUT (i.e. the JPF side)
57   String failedClass;
58
59   public ClassInfoException(String details, ClassLoaderInfo cl, String exceptionClass, String faildClass) {
60     super(details);
61     this.classLoader = cl;
62     this.exceptionClass = exceptionClass;
63     this.failedClass = faildClass;
64   }
65
66   public ClassInfoException (String details, ClassLoaderInfo cl, String exceptionClass, String faildClass, Throwable cause) {
67     super(details, cause);
68     this.classLoader = cl;
69     this.exceptionClass = exceptionClass;
70     this.failedClass = faildClass;
71   }
72
73   
74   public boolean checkSystemClassFailure() {
75     return (failedClass.startsWith("java."));
76   }
77
78   public ClassLoaderInfo getClassLoaderInfo() {
79     return classLoader;
80   }
81
82   public String getFailedClass() {
83     return failedClass;
84   }
85
86   public String getExceptionClass() {
87     return exceptionClass;
88   }
89 }