2 * Copyright (C) 2014, United States Government, as represented by the
3 * Administrator of the National Aeronautics and Space Administration.
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
10 * http://www.apache.org/licenses/LICENSE-2.0.
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.
18 package gov.nasa.jpf.vm;
20 import java.io.PrintWriter;
23 * helper class to store context of an exception
25 public class ExceptionInfo {
29 ExceptionInfo (ThreadInfo xThread, ElementInfo xEi) {
34 public ElementInfo getException() {
38 public int getExceptionReference () {
39 return ei.getObjectRef();
42 public String getExceptionClassname() {
43 return ei.getClassInfo().getName();
46 public String getDetails() {
47 StringBuilder sb = new StringBuilder();
48 sb.append(getExceptionClassname());
50 int msgRef = ei.getReferenceField("detailMessage");
51 if (msgRef != MJIEnv.NULL){
52 ElementInfo eiMsg = ti.getElementInfo(msgRef);
54 sb.append(eiMsg.asString());
60 public String getCauseClassname() {
61 int causeRef = ei.getReferenceField("cause");
62 if (causeRef != MJIEnv.NULL){
63 ElementInfo eiCause = ti.getElementInfo(causeRef);
64 return eiCause.getClassInfo().getName();
69 public String getCauseDetails() {
70 int causeRef = ei.getReferenceField("cause");
71 if (causeRef != MJIEnv.NULL){
72 ElementInfo eiCause = ti.getElementInfo(causeRef);
73 int msgRef = eiCause.getReferenceField("detailMessage");
74 if (msgRef != MJIEnv.NULL){
75 ElementInfo eiMsg = ti.getElementInfo(msgRef);
76 return eiMsg.asString();
84 public ThreadInfo getThread() {
88 public void printOn (PrintWriter pw){
89 ti.printStackTrace(pw, ei.getObjectRef());