KickJava   Java API By Example, From Geeks To Geeks.

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


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.io.ObjectInputStream
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 JavaIoObjectInputStreamNative extends NativeMethodClass {
34     public JavaIoObjectInputStreamNative( 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.ClassLoader latestUserDefinedLoader()")){
49       java_io_ObjectInputStream_latestUserDefinedLoader(method,
50                             thisVar,
51                             returnVar,
52                             params);
53       return;
54
55     } else if (subSignature.equals("java.lang.Object allocateNewObject(java.lang.Class,java.lang.Class)")) {
56       java_io_ObjectInputStream_allocateNewObject(method,
57                           thisVar,
58                           returnVar,
59                           params);
60       return;
61
62     } else if (subSignature.equals("java.lang.Object allocateNewArray(java.lang.Class,int)")){
63       java_io_ObjectInputStream_allocateNewArray(method,
64                          thisVar,
65                          returnVar,
66                          params);
67       return;
68
69     } else {
70       defaultMethod(method, thisVar, returnVar, params);
71       return;
72
73     }
74   }
75
76   /*********************** java.io.ObjectInputStream *******************/
77   /**
78    * NOTE: conservatively returns a reference pointing to the only copy
79    * of the class loader.
80    *
81    * private static native java.lang.ClassLoader latestUserDefinedLoader()
82    * throws java.lang.ClassNotFoundException;
83    */

84   public
85     void java_io_ObjectInputStream_latestUserDefinedLoader(
86                         SootMethod method,
87                     ReferenceVariable thisVar,
88                     ReferenceVariable returnVar,
89                     ReferenceVariable params[]){
90     helper.assignObjectTo(returnVar, Environment.v().getClassLoaderObject());
91   }
92
93   /**
94    * Serialization has to be avoided by static analyses, since each
95    * object comes out of the same place.
96    *
97    * private static native java.lang.Object allocateNewObject(java.lang.Class,
98    * java.lang.Class)
99    * throws java.lang.InstantiationException,
100    * java.lang.IllegalAccessException;
101    */

102   public
103     void java_io_ObjectInputStream_allocateNewObject(
104                          SootMethod method,
105                                                  ReferenceVariable thisVar,
106                          ReferenceVariable returnVar,
107                          ReferenceVariable params[]){
108     throw new NativeMethodNotSupportedException(method);
109   }
110
111   /**
112    * private static native java.lang.Object allocateNewArray(java.lang.Class,
113    * int);
114    */

115   public
116     void java_io_ObjectInputStream_allocateNewArray(
117                          SootMethod method,
118                          ReferenceVariable thisVar,
119                          ReferenceVariable returnVar,
120                          ReferenceVariable params[]){
121     throw new NativeMethodNotSupportedException(method);
122   }
123
124   /**
125    * Following methods have NO side effect, (the last one?????)
126    * to be verified with serialization and de-serialization.
127    *
128    * private static native void bytesToFloats(byte[], int, float[], int, int);
129    * private static native void bytesToDoubles(byte[], int,
130    * double[], int, int);
131    * private static native void setPrimitiveFieldValues(java.lang.Object,
132    * long[],
133    * char[],
134    * byte[]);
135    * private static native void setObjectFieldValue(java.lang.Object,
136    * long,
137    * java.lang.Class,
138    * java.lang.Object);
139    */

140
141 }
142
Popular Tags