KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > soot > jimple > toolkits > pointer > nativemethods > JavaLangReflectArrayNative


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  * Simulates the native method side effects in class java.lang.reflect.Array
22  *
23  * @author Feng Qian
24  * @author <XXX>
25  */

26
27 package soot.jimple.toolkits.pointer.nativemethods;
28
29 import soot.*;
30 import soot.jimple.toolkits.pointer.representations.*;
31 import soot.jimple.toolkits.pointer.util.*;
32
33 public class JavaLangReflectArrayNative extends NativeMethodClass {
34     public JavaLangReflectArrayNative( NativeHelper helper ) { super(helper); }
35
36   /**
37    * Implements the abstract method simulateMethod.
38    * It distributes the request to the corresponding methods
39    * by signatures.
40    */

41   public void simulateMethod(SootMethod method,
42                  ReferenceVariable thisVar,
43                  ReferenceVariable returnVar,
44                  ReferenceVariable params[]){
45
46     String JavaDoc subSignature = method.getSubSignature();
47
48     if (subSignature.equals("java.lang.Object get(java.lang.Object,int)")) {
49       java_lang_reflect_Array_get(method, thisVar, returnVar, params);
50       return;
51
52     } else if (subSignature.equals("void set(java.lang.Object,int,java.lang.Object)")) {
53       java_lang_reflect_Array_set(method, thisVar, returnVar, params);
54       return;
55
56     } else if (subSignature.equals("java.lang.Object newArray(java.lang.Class,int)")){
57       java_lang_reflect_Array_newArray(method, thisVar, returnVar, params);
58       return;
59
60     } else if (subSignature.equals("java.lang.Object multiNewArray(java.lang.Class,int[])")){
61       java_lang_reflect_Array_multiNewArray(method, thisVar,
62                         returnVar, params);
63       return;
64
65     } else {
66       defaultMethod(method, thisVar, returnVar, params);
67       return;
68
69     }
70   }
71   /************ java.lang.reflect.Array **********************/
72   /**
73    * Returns the value of the indexed component in the specified array
74    * object. The value is automatically wrapped in an object if it has
75    * a primitive type.
76    *
77    * NOTE: @return = @param0[]
78    *
79    * public static native java.lang.Object get(java.lang.Object, int)
80    * throws java.lang.IllegalArgumentException,
81    * java.lang.ArrayIndexOutOfBoundsException;
82    */

83   public
84     void java_lang_reflect_Array_get(SootMethod method,
85                      ReferenceVariable thisVar,
86                      ReferenceVariable returnVar,
87                      ReferenceVariable params[]){
88     throw new NativeMethodNotSupportedException(method);
89   }
90   
91   /**
92    * @param0[] = @param1
93    *
94    * public static native void set(java.lang.Object, int, java.lang.Object)
95    * throws java.lang.IllegalArgumentException,
96    * java.lang.ArrayIndexOutOfBoundsException;
97    */

98   public
99     void java_lang_reflect_Array_set(SootMethod method,
100                      ReferenceVariable thisVar,
101                      ReferenceVariable returnVar,
102                      ReferenceVariable params[]){
103     throw new NativeMethodNotSupportedException(method);
104   }
105
106   /**
107    * Treat this method as
108    * @return = new A[];
109    *
110    * private static native java.lang.Object newArray(java.lang.Class, int)
111    * throws java.lang.NegativeArraySizeException;
112    */

113   public
114     void java_lang_reflect_Array_newArray(SootMethod method,
115                       ReferenceVariable thisVar,
116                       ReferenceVariable returnVar,
117                       ReferenceVariable params[]){
118     throw new NativeMethodNotSupportedException(method);
119   }
120
121   /**
122    * Treat this method as
123    * @return = new A[][];
124    *
125    * private static native java.lang.Object multiNewArray(java.lang.Class,
126    * int[])
127    * throws java.lang.IllegalArgumentException,
128    * java.lang.NegativeArraySizeException;
129    */

130   public
131     void java_lang_reflect_Array_multiNewArray(SootMethod method,
132                            ReferenceVariable thisVar,
133                            ReferenceVariable returnVar,
134                            ReferenceVariable params[]){
135     throw new NativeMethodNotSupportedException(method);
136   }
137
138   /**
139    * Following native methods have no side effects.
140    *
141    * public static native int getLength(java.lang.Object)
142    * throws java.lang.IllegalArgumentException;
143    *
144    * public static native boolean getBoolean(java.lang.Object, int)
145    * throws java.lang.IllegalArgumentException,
146    * java.lang.ArrayIndexOutOfBoundsException;
147    *
148    * public static native byte getByte(java.lang.Object, int)
149    * throws java.lang.IllegalArgumentException,
150    * java.lang.ArrayIndexOutOfBoundsException;
151    *
152    * public static native char getChar(java.lang.Object, int)
153    * throws java.lang.IllegalArgumentException,
154    * java.lang.ArrayIndexOutOfBoundsException;
155    *
156    * public static native short getShort(java.lang.Object, int)
157    * throws java.lang.IllegalArgumentException,
158    * java.lang.ArrayIndexOutOfBoundsException;
159    *
160    * public static native int getInt(java.lang.Object, int)
161    * throws java.lang.IllegalArgumentException,
162    * java.lang.ArrayIndexOutOfBoundsException;
163    *
164    * public static native long getLong(java.lang.Object, int)
165    * throws java.lang.IllegalArgumentException,
166    * java.lang.ArrayIndexOutOfBoundsException;
167    *
168    * public static native float getFloat(java.lang.Object, int)
169    * throws java.lang.IllegalArgumentException,
170    * java.lang.ArrayIndexOutOfBoundsException;
171    *
172    * public static native double getDouble(java.lang.Object, int)
173    * throws java.lang.IllegalArgumentException,
174    * java.lang.ArrayIndexOutOfBoundsException;
175    *
176    * public static native void setBoolean(java.lang.Object, int, boolean)
177    * throws java.lang.IllegalArgumentException,
178    * java.lang.ArrayIndexOutOfBoundsException;
179    *
180    * public static native void setByte(java.lang.Object, int, byte)
181    * throws java.lang.IllegalArgumentException,
182    * java.lang.ArrayIndexOutOfBoundsException;
183    *
184    * public static native void setChar(java.lang.Object, int, char)
185    * throws java.lang.IllegalArgumentException,
186    * java.lang.ArrayIndexOutOfBoundsException;
187    *
188    * public static native void setShort(java.lang.Object, int, short)
189    * throws java.lang.IllegalArgumentException,
190    * java.lang.ArrayIndexOutOfBoundsException;
191    *
192    * public static native void setInt(java.lang.Object, int, int)
193    * throws java.lang.IllegalArgumentException,
194    * java.lang.ArrayIndexOutOfBoundsException;
195    *
196    * public static native void setLong(java.lang.Object, int, long)
197    * throws java.lang.IllegalArgumentException,
198    * java.lang.ArrayIndexOutOfBoundsException;
199    *
200    * public static native void setFloat(java.lang.Object, int, float)
201    * throws java.lang.IllegalArgumentException,
202    * java.lang.ArrayIndexOutOfBoundsException;
203    *
204    * public static native void setDouble(java.lang.Object, int, double)
205    * throws java.lang.IllegalArgumentException,
206    * java.lang.ArrayIndexOutOfBoundsException;
207    * @see default(...)
208    */

209 }
210
Popular Tags