KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > soot > toolkits > exceptions > PedanticThrowAnalysis


1 /* Soot - a J*va Optimization Framework
2  * Copyright (C) 2003 John Jorgensen
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */

19
20 package soot.toolkits.exceptions;
21
22 import soot.Unit;
23 import soot.Singletons;
24 import soot.G;
25 import soot.toolkits.exceptions.*;
26 import soot.baf.ThrowInst;
27 import soot.jimple.ThrowStmt;
28
29 /**
30  * A {@link ThrowAnalysis} that says that every unit can throw every
31  * possible exception type. Strictly speaking, this is correct, since
32  * the deprecated {@link java.lang.Thread#stop(Throwable)} method
33  * allows one thread to cause any {@link Throwable} it wants to be
34  * thrown in another thread, meaning that all {@link Throwable}s may
35  * arrive asynchronously from the perspective of the victim thread.
36  */

37 public class PedanticThrowAnalysis extends AbstractThrowAnalysis {
38
39     /**
40      * Constructs a <code>PedanticThrowAnalysis</code> for inclusion in
41      * Soot's global variable manager, {@link G}.
42      *
43      * @param g guarantees that the constructor may only be called
44      * from {@link Singletons}.
45      */

46     public PedanticThrowAnalysis(Singletons.Global g) {}
47
48     /**
49      * Returns the single instance of <code>PedanticThrowAnalysis</code>.
50      *
51      * @return Soot's <code>PedanticThrowAnalysis</code>.
52      */

53     public static PedanticThrowAnalysis v() {
54     return G.v().soot_toolkits_exceptions_PedanticThrowAnalysis();
55     }
56
57
58     /**
59      * Returns the set of all <code>Throwable</code>s as the set
60      * of types that the specified unit might throw, regardless of the
61      * unit's identity.
62      *
63      * @param u {@link Unit} whose exceptions are to be returned.
64      *
65      * @return the set of all <code>Throwable</code>s.
66      */

67     public ThrowableSet mightThrow(Unit u) {
68     return ThrowableSet.Manager.v().ALL_THROWABLES;
69     }
70
71
72     /**
73      * Returns the set of all <code>Throwable</code>s as the set
74      * of types that a <code>throw</code> instruction may throw implicitly,
75      * that is, the possible types of errors which might arise in
76      * the course of executing the <code>throw</code> instruction, rather
77      * than the type of the <code>throw</code>'s operand.
78      *
79      * @param t the {@link ThrowInst} whose exceptions are to be returned.
80      *
81      * @return the set of all <code>Throwable</code>s.
82      */

83     public ThrowableSet mightThrowImplicitly(ThrowInst t) {
84     return ThrowableSet.Manager.v().ALL_THROWABLES;
85     }
86
87
88     /**
89      * Returns the set of all <code>Throwable</code>s as the set
90      * of types that a <code>throw</code> statement may throw implicitly,
91      * that is, the possible types of errors which might arise in
92      * the course of executing the <code>throw</code> statement, rather
93      * than the type of the <code>throw</code>'s operand.
94      *
95      * @param t the {@link ThrowStmt} whose exceptions are to be returned.
96      *
97      * @return the set of all <code>Throwable</code>s.
98      */

99     public ThrowableSet mightThrowImplicitly(ThrowStmt t) {
100     return ThrowableSet.Manager.v().ALL_THROWABLES;
101     }
102 }
103
104
Popular Tags