01: /* Soot - a J*va Optimization Framework
02: * Copyright (C) 2003 Feng Qian
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2.1 of the License, or (at your option) any later version.
08: *
09: * 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.Constructor
22: *
23: * @author Feng Qian
24: * @author <XXX>
25: */package soot.jimple.toolkits.pointer.nativemethods;
26:
27: import soot.*;
28: import soot.jimple.toolkits.pointer.representations.*;
29: import soot.jimple.toolkits.pointer.util.*;
30:
31: public class JavaLangReflectConstructorNative extends NativeMethodClass {
32: public JavaLangReflectConstructorNative(NativeHelper helper) {
33: super (helper);
34: }
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 this Var, ReferenceVariable returnVar,
43: ReferenceVariable params[]) {
44:
45: String subSignature = method.getSubSignature();
46:
47: if (subSignature
48: .equals("java.lang.Object newInstance(java.lang.Object[])")) {
49: java_lang_reflect_Constructor_newInstance(method, this Var,
50: returnVar, params);
51: return;
52:
53: } else {
54: defaultMethod(method, this Var, returnVar, params);
55: return;
56:
57: }
58: }
59:
60: /********************** java.lang.reflect.Constructor ****************/
61: /**
62: * Uses the constructor represented by this Constructor object to
63: * create and initialize a new instance of the constructor's
64: * declaring class, with the specified initialization
65: * parameters. Individual parameters are automatically unwrapped to
66: * match primitive formal parameters, and both primitive and
67: * reference parameters are subject to method invocation conversions
68: * as necessary. Returns the newly created and initialized object.
69: *
70: * NOTE: @return = new Object; but we lose type information.
71: *
72: * public native java.lang.Object newInstance(java.lang.Object[])
73: * throws java.lang.InstantiationException,
74: * java.lang.IllegalAccessException,
75: * java.lang.IllegalArgumentException,
76: * java.lang.reflect.InvocationTargetException;
77: */
78: public void java_lang_reflect_Constructor_newInstance(
79: SootMethod method, ReferenceVariable this Var,
80: ReferenceVariable returnVar, ReferenceVariable params[]) {
81: throw new NativeMethodNotSupportedException(method);
82: }
83: }
|