KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > soot > jimple > toolkits > pointer > representations > Environment


1 /* Soot - a J*va Optimization Framework
2  * Copyright (C) 2003 Feng Qian
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 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  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser 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 /**
21  * Environment simulates the VM environment such as objects representing
22  * classes, methods, fields, and so on. There is only one:
23  *
24  * java.lang.ClassLoader object,
25  * java.lang.Class object,
26  * java.lang.Field object,
27  * java.lang.Method object,
28  * java.lang.Constructor object,
29  * java.lang.Process object,
30  * java.lang.Thread object,
31  * java.io.FileSystem object
32  *
33  * String objects are special, since there are other string constants.
34  * An unknown object has the least type, same as array.
35  *
36  * This class defines all abstract object as constants.
37  * Temporary variables can be obtained from NativeHelper.
38  *
39  * @author Feng Qian
40  */

41
42 package soot.jimple.toolkits.pointer.representations;
43
44 import soot.*;
45 import java.util.*;
46
47 public class Environment {
48     public Environment( Singletons.Global g ) {}
49     public static Environment v() { return G.v().soot_jimple_toolkits_pointer_representations_Environment(); }
50
51   private ConstantObject clsloaders =
52     new GeneralConstObject(TypeConstants.v().CLASSLOADERCLASS, "classloader");
53   
54   private ConstantObject processes =
55     new GeneralConstObject(TypeConstants.v().PROCESSCLASS, "process");
56
57   private ConstantObject threads =
58     new GeneralConstObject(TypeConstants.v().THREADCLASS, "thread");
59
60   private ConstantObject filesystem =
61     new GeneralConstObject(TypeConstants.v().FILESYSTEMCLASS, "filesystem");
62
63   /* representing all possible java.lang.Class type objects,
64    * mostly used by reflection.
65    */

66   private ConstantObject classobject =
67     new GeneralConstObject(TypeConstants.v().CLASSCLASS, "unknownclass");
68
69   /* representing all possible java.lang.String objects, used by
70    * any getName() or similiar methods.
71    */

72   private ConstantObject stringobject =
73     new GeneralConstObject(TypeConstants.v().STRINGCLASS, "unknownstring");
74
75   /* to get finer resolution, it is worth to distinguish arrays and general
76    * scalars.
77    * WARNING: making array with java.lang.Object type may be a problem!
78    */

79   private ConstantObject leastarray =
80     new GeneralConstObject(TypeConstants.v().LEASTCLASS, "leastarray");
81
82   /* makes a general unknown object,
83    * WARNING: unknown object must have the least type, it won't be
84    * useful when resolve virtual calls.
85    * Null type is a good candidate for this.
86    */

87   private ConstantObject leastobject =
88     new GeneralConstObject(TypeConstants.v().LEASTCLASS, "leastobject");
89
90   /* provides an abstract java.lang.reflect.Field object.
91    */

92   private ConstantObject fieldobject =
93     new GeneralConstObject(TypeConstants.v().FIELDCLASS, "field");
94
95   /* provides an abstract java.lang.reflect.Method object
96    */

97   private ConstantObject methodobject =
98     new GeneralConstObject(TypeConstants.v().METHODCLASS, "method");
99   
100   /* provides an abstract java.lang.reflect.Constructor object
101    */

102   private ConstantObject constructorobject =
103     new GeneralConstObject(TypeConstants.v().CONSTRUCTORCLASS, "constructor");
104
105   /* represents the PrivilegedActionException thrown by
106    * AccessController.doPrivileged
107    */

108   private ConstantObject privilegedActionException =
109     new GeneralConstObject(TypeConstants.v().PRIVILEGEDACTIONEXCEPTION, "constructor");
110
111   /********************* INTERFACE to NATIVE METHODS *******************/
112   public ConstantObject getClassLoaderObject(){
113     return clsloaders;
114   }
115
116   public ConstantObject getProcessObject(){
117     return processes;
118   }
119
120   public ConstantObject getThreadObject(){
121     return threads;
122   }
123
124   public ConstantObject getClassObject(){
125     return classobject;
126   }
127
128   public ConstantObject getStringObject(){
129     return stringobject;
130   }
131
132   public ConstantObject getLeastArrayObject(){
133     return leastarray;
134   }
135   
136   public ConstantObject getLeastObject(){
137     return leastobject;
138   }
139
140   public ConstantObject getFieldObject(){
141     return fieldobject;
142   }
143
144   public ConstantObject getMethodObject(){
145     return methodobject;
146   }
147
148   public ConstantObject getConstructorObject(){
149     return constructorobject;
150   }
151
152   public ConstantObject getFileSystemObject(){
153     return filesystem;
154   }
155
156   public ConstantObject getPrivilegedActionExceptionObject(){
157     return privilegedActionException;
158   }
159 }
160
Popular Tags