1 cananian 1.6.2.4  // HClassSyn.java, created Wed Oct 14 16:03:26 1998 by cananian
  2 cananian 1.1      // Copyright (C) 1998 C. Scott Ananian <cananian@alumni.princeton.edu>
  3 cananian 1.1      // Licensed under the terms of the GNU GPL; see COPYING for details.
  4 cananian 1.1      package harpoon.ClassFile;
  5 cananian 1.1      
  6 cananian 1.1      import java.lang.reflect.Modifier;
  7 cananian 1.1      
  8 cananian 1.1      import harpoon.Util.Util;
  9 cananian 1.1      
 10 cananian 1.1      /**
 11 cananian 1.1       * Instances of the class <code>HClassSyn</code> represent modifiable
 12 cananian 1.1       * classes and interfaces of a java program.  Arrays and primitive types
 13 cananian 1.1       * are not modifiable, and thus are not represented by 
 14 cananian 1.6.2.17  * <code>HClassSyn</code>.
 15 cananian 1.1       * 
 16 cananian 1.1       * @author  C. Scott Ananian <cananian@alumni.princeton.edu>
 17 cananian 1.9       * @version $Id: HClassSyn.java,v 1.9 2002/04/10 03:04:12 cananian Exp $
 18 cananian 1.1       * @see harpoon.ClassFile.HClass
 19 cananian 1.1       */
 20 cananian 1.6.2.10 class HClassSyn extends HClassCls implements HClassMutator {
 21 cananian 1.6.2.10 
 22 cananian 1.6.2.10   /** Create an <code>HClassSyn</code> from a template <code>HClass</code>.
 23 cananian 1.6.2.10    *  The new <code>HClassSyn</code> will have the (fully-qualified)
 24 cananian 1.6.2.10    *  name specified by the <code>name</code> parameter.
 25 cananian 1.6.2.10    * @param template The template class to use.
 26 cananian 1.6.2.10    * @param name The fully-qualified name for this class object.
 27 cananian 1.6.2.10    */
 28 cananian 1.6.2.10   HClassSyn(Linker l, String name, HClass template) {
 29 cananian 1.6.2.10     super(l);
 30 cananian 1.8.2.1      assert !template.isArray();
 31 cananian 1.8.2.1      assert !template.isPrimitive();
 32 cananian 1.8.2.1      assert l==template.getLinker();
 33 cananian 1.6.2.10     this.name = name;
 34 cananian 1.1          this.superclass = template.getSuperclass();
 35 cananian 1.1          this.interfaces = template.getInterfaces();
 36 cananian 1.1          this.modifiers  = template.getModifiers();
 37 cananian 1.6          this.sourcefile = template.getSourceFile();
 38 cananian 1.6      
 39 cananian 1.6          this.declaredFields = new HFieldSyn[0];
 40 cananian 1.6          HField fields[] = template.getDeclaredFields();
 41 cananian 1.6.2.10     for (int i=0; i < fields.length; i++)
 42 cananian 1.6.2.10       addDeclaredField(fields[i].getName(), fields[i]);
 43 cananian 1.8.2.1      assert fields.length == declaredFields.length;
 44 cananian 1.6      
 45 nkushman 1.5          this.declaredMethods= new HMethodSyn[0];
 46 nkushman 1.5          HMethod methods[] = template.getDeclaredMethods();
 47 cananian 1.6.2.10     for (int i = 0; i < methods.length; i++)
 48 cananian 1.6.2.10       if (methods[i] instanceof HInitializer)
 49 cananian 1.6.2.10         addClassInitializer();
 50 cananian 1.6.2.10       else if (methods[i] instanceof HConstructor)
 51 cananian 1.6.2.10         addConstructor((HConstructor)methods[i]);
 52 cananian 1.6.2.7        else
 53 cananian 1.6.2.10         addDeclaredMethod(methods[i].getName(), methods[i]);
 54 cananian 1.8.2.1      assert methods.length == declaredMethods.length;
 55 cananian 1.6.2.10 
 56 cananian 1.6.2.12     // ensure linker information is consistent.
 57 cananian 1.8.2.1      assert this.superclass==null || checkLinker((HClass)this.superclass);
 58 cananian 1.6.2.12     for (int i=0; i<this.interfaces.length; i++)
 59 cananian 1.8.2.1        assert checkLinker((HClass)this.interfaces[i]);
 60 cananian 1.6.2.12 
 61 cananian 1.6.2.10     hasBeenModified = true; // by default, mark this as 'modified'
 62 cananian 1.1        }
 63 cananian 1.6.2.17   /** private constructor for serialization. */
 64 cananian 1.6.2.17   private HClassSyn(Linker l, String name,
 65 cananian 1.6.2.17                     HClass superclass, HClass[] interfaces,
 66 cananian 1.6.2.18                     int modifiers, String sourcefile) {
 67 cananian 1.6.2.17     super(l);
 68 cananian 1.6.2.17     this.name = name;
 69 cananian 1.6.2.17     this.superclass = superclass;
 70 cananian 1.6.2.17     this.interfaces = interfaces;
 71 cananian 1.6.2.17     this.modifiers  = modifiers;
 72 cananian 1.3          this.sourcefile = sourcefile;
 73 cananian 1.6.2.18     this.declaredFields = null; // fill in during second pass
 74 cananian 1.6.2.18     this.declaredMethods= null; // fill in during second pass
 75 cananian 1.6.2.18     this.hasBeenModified = false; // fill in during second pass
 76 cananian 1.6.2.17   }
 77 cananian 1.6.2.10   public HClassMutator getMutator() { return this; }
 78 cananian 1.1      
 79 cananian 1.6.2.10   // implementation of HClassMutator.
 80 cananian 1.6.2.10   public HField addDeclaredField(String name, HClass type) {
 81 cananian 1.6.2.10     return addDeclaredField0(new HFieldSyn(this, name, type));
 82 cananian 1.6.2.10   }
 83 cananian 1.6.2.10   public HField addDeclaredField(String name, String descriptor) {
 84 cananian 1.6.2.10     return addDeclaredField0(new HFieldSyn(this, name, descriptor));
 85 cananian 1.6.2.10   }
 86 cananian 1.6.2.10   public HField addDeclaredField(String name, HField template) {
 87 cananian 1.6.2.10     return addDeclaredField0(new HFieldSyn(this, name, template));
 88 cananian 1.6.2.10   }
 89 cananian 1.6.2.10   // deal with array housekeeping.
 90 cananian 1.6.2.10   private HField addDeclaredField0(HField f) {
 91 cananian 1.8.2.1      assert f.getDeclaringClass()==this;
 92 cananian 1.6.2.10     for (int i=0; i<declaredFields.length; i++)
 93 cananian 1.6.2.10       if (declaredFields[i].equals(f))
 94 cananian 1.6.2.10         throw new DuplicateMemberException("Field "+f+" in "+this);
 95 cananian 1.2          declaredFields = 
 96 cananian 1.6.2.1        (HField[]) Util.grow(HField.arrayFactory,
 97 cananian 1.6.2.1                             declaredFields, f, declaredFields.length);
 98 cananian 1.4          fields=null; // invalidate cache.
 99 cananian 1.6.2.10     hasBeenModified=true; // flag the modification
100 cananian 1.6.2.10     return f;
101 cananian 1.2        }
102 cananian 1.2        public void removeDeclaredField(HField f) throws NoSuchFieldError {
103 cananian 1.2          for (int i=0; i<declaredFields.length; i++) {
104 cananian 1.2            if (declaredFields[i].equals(f)) {
105 cananian 1.6.2.1          declaredFields = (HField[]) Util.shrink(HField.arrayFactory,
106 cananian 1.6.2.1                                                  declaredFields, i);
107 cananian 1.4              fields=null; // invalidate cache.
108 cananian 1.6.2.10         hasBeenModified=true; // flag the modification
109 cananian 1.2              return;
110 cananian 1.2            }
111 cananian 1.2          }
112 cananian 1.6.2.10     throw new NoSuchMemberException("Field "+f);
113 cananian 1.1        }
114 cananian 1.1      
115 cananian 1.6.2.10   public HInitializer addClassInitializer() {
116 cananian 1.6.2.10     return (HInitializer)
117 cananian 1.6.2.10       addDeclaredMethod0(new HInitializerSyn(this));
118 cananian 1.6.2.10   }
119 cananian 1.6.2.10   public void removeClassInitializer(HInitializer m) {
120 cananian 1.6.2.10     removeDeclaredMethod(m);
121 cananian 1.6.2.10   }
122 cananian 1.6.2.10   public HConstructor addConstructor(String descriptor) {
123 cananian 1.6.2.10     return (HConstructor)
124 cananian 1.6.2.10       addDeclaredMethod0(new HConstructorSyn(this, descriptor));
125 cananian 1.6.2.10   }
126 cananian 1.6.2.10   public HConstructor addConstructor(HClass[] paramTypes) {
127 cananian 1.6.2.16     for (int i=0; i<paramTypes.length; i++)
128 cananian 1.8.2.1        assert checkLinker(paramTypes[i]);
129 cananian 1.6.2.10     return (HConstructor)
130 cananian 1.6.2.10       addDeclaredMethod0(new HConstructorSyn(this, paramTypes));
131 cananian 1.6.2.10   }
132 cananian 1.6.2.10   public HConstructor addConstructor(HConstructor template) {
133 cananian 1.6.2.10     return (HConstructor)
134 cananian 1.6.2.10       addDeclaredMethod0(new HConstructorSyn(this, template));
135 cananian 1.6.2.10   }
136 cananian 1.6.2.10   public void removeConstructor(HConstructor c) {
137 cananian 1.6.2.10     removeDeclaredMethod(c);
138 cananian 1.6.2.10   }
139 cananian 1.6.2.10   public HMethod addDeclaredMethod(String name, String descriptor) {
140 cananian 1.8.2.1      assert !name.equals("<init>") && !name.equals("<clinit>");
141 cananian 1.6.2.10     return addDeclaredMethod0(new HMethodSyn(this, name, descriptor));
142 cananian 1.6.2.10   }
143 cananian 1.6.2.10   public HMethod addDeclaredMethod(String name, HClass[] paramTypes,
144 cananian 1.6.2.10                                    HClass returnType) {
145 cananian 1.8.2.1      assert !name.equals("<init>") && !name.equals("<clinit>");
146 cananian 1.8.2.1      assert checkLinker(returnType);
147 cananian 1.6.2.16     for (int i=0; i<paramTypes.length; i++)
148 cananian 1.8.2.1        assert checkLinker(paramTypes[i]);
149 cananian 1.6.2.10     return addDeclaredMethod0(new HMethodSyn(this,name,paramTypes,returnType));
150 cananian 1.6.2.10   }
151 cananian 1.6.2.10   public HMethod addDeclaredMethod(String name, HMethod template) {
152 cananian 1.8.2.1      assert !name.equals("<init>") && !name.equals("<clinit>");
153 cananian 1.6.2.10     return addDeclaredMethod0(new HMethodSyn(this, name, template));
154 cananian 1.6.2.10   }
155 cananian 1.6.2.10 
156 cananian 1.6.2.10   private HMethod addDeclaredMethod0(HMethod m) {
157 cananian 1.8.2.1      assert m.getDeclaringClass()==this;
158 cananian 1.6.2.10     for (int i=0; i<declaredMethods.length; i++)
159 cananian 1.6.2.10       if (declaredMethods[i].equals(m))
160 cananian 1.6.2.10         throw new DuplicateMemberException("Method "+m+" in "+this);
161 cananian 1.2          declaredMethods = 
162 cananian 1.6.2.1        (HMethod[]) Util.grow(HMethod.arrayFactory,
163 cananian 1.6.2.1                              declaredMethods, m, declaredMethods.length);
164 cananian 1.4          methods=null; // invalidate cache.
165 cananian 1.4          constructors=null;
166 cananian 1.6.2.10     hasBeenModified=true; // flag the modification
167 cananian 1.6.2.10     return m;
168 cananian 1.2        }
169 cananian 1.2        public void removeDeclaredMethod(HMethod m) throws NoSuchMethodError {
170 cananian 1.2          for (int i=0; i<declaredMethods.length; i++) {
171 cananian 1.2            if (declaredMethods[i].equals(m)) {
172 cananian 1.6.2.1          declaredMethods = (HMethod[]) Util.shrink(HMethod.arrayFactory,
173 cananian 1.6.2.1                                                    declaredMethods, i);
174 cananian 1.4              methods=null; // invalidate cache.
175 cananian 1.4              constructors=null;
176 cananian 1.6.2.10         hasBeenModified=true; // flag the modification
177 cananian 1.2              return;
178 cananian 1.1            }
179 cananian 1.2          }
180 cananian 1.6.2.10     throw new NoSuchMemberException("Method "+m);
181 cananian 1.1        }
182 cananian 1.2      
183 cananian 1.6.2.10   public void addModifiers(int m) { setModifiers(getModifiers()|m); }
184 cananian 1.6.2.10   public void removeModifiers(int m){ setModifiers(getModifiers()&(~m)); }
185 cananian 1.2        public void setModifiers(int m) { 
186 cananian 1.6          // are we changing an interface to a class?
187 cananian 1.6          if ( Modifier.isInterface(modifiers) && !Modifier.isInterface(m)) {
188 cananian 1.6            // make sure there are no superclasses or superinterfaces.
189 cananian 1.8.2.1        assert superclass==null; // should be true for interfaces.
190 cananian 1.6            if (interfaces.length!=0)
191 cananian 1.6              throw new Error("Can't change a subinterface to a class. "+
192 cananian 1.6                              "Remove the inheritance first. ("+this+")");
193 cananian 1.6            // inherit from java.lang.Object.
194 cananian 1.6.2.10       superclass = getLinker().forName("java.lang.Object");
195 cananian 1.6            // tag all the methods as abstract.
196 cananian 1.6            for (int i=0; i<declaredMethods.length; i++)
197 cananian 1.6              ((HMethodSyn)declaredMethods[i]).setModifiers
198 cananian 1.6                (declaredMethods[i].getModifiers() | Modifier.ABSTRACT);
199 cananian 1.6          }
200 cananian 1.6          // are we changing a class to an interface?
201 cananian 1.6          if (!Modifier.isInterface(modifiers) &&  Modifier.isInterface(m)) {
202 cananian 1.6            // make sure there are no superclasses or superinterfaces.
203 cananian 1.6            if (superclass != null && 
204 cananian 1.6.2.10           superclass.actual() != getLinker().forName("java.lang.Object"))
205 cananian 1.6              throw new Error("Can't change a subclass to an interface. "+
206 cananian 1.6                              "Remove the inheritance first. ("+this+")");
207 cananian 1.6            if (interfaces.length!=0)
208 cananian 1.6              throw new Error("Can't change a class implementing interfaces "+
209 cananian 1.6                              "to an interface itself. Remove the inheritance "+
210 cananian 1.6                              "first. ("+this+")");
211 cananian 1.6            // interfaces have no superclass.
212 cananian 1.6            superclass = null;
213 cananian 1.6.2.10       // tag all the methods as abstract
214 cananian 1.6            for (int i=0; i<declaredMethods.length; i++) {
215 cananian 1.6              HMethodSyn hm = (HMethodSyn) declaredMethods[i];
216 cananian 1.6              hm.setModifiers(hm.getModifiers() | Modifier.ABSTRACT);
217 cananian 1.6            }
218 cananian 1.6          }
219 cananian 1.6.2.10     if (modifiers!=m) hasBeenModified=true; // flag the modification
220 cananian 1.2          modifiers = m;
221 cananian 1.1        }
222 cananian 1.2      
223 cananian 1.2        public void setSuperclass(HClass sc) {
224 cananian 1.6          if (sc==null)
225 cananian 1.6            throw new Error("This is very odd.  " +
226 cananian 1.6                            "Do you realize you're trying to create a new "+
227 cananian 1.6                            "top-level object?  I'm not sure I should allow this."+
228 cananian 1.6                            "  Please mail me at cananian@alumni.princeton.edu and "+
229 cananian 1.6                            "tell me why you think it's a good idea.");
230 cananian 1.8.2.1      assert !sc.isPrimitive();
231 cananian 1.8.2.1      assert checkLinker(sc);
232 cananian 1.6          // XXX more sanity checks?
233 cananian 1.6.2.10     if (superclass != sc) hasBeenModified=true; // flag the modification
234 cananian 1.2          superclass = sc;
235 cananian 1.6.2.10     constructors=null;
236 cananian 1.6.2.10     fields = null;
237 cananian 1.6.2.10     methods = null;
238 cananian 1.1        }
239 cananian 1.1      
240 cananian 1.1        public void addInterface(HClass in) {
241 cananian 1.2          if (!in.isInterface()) throw new Error("Not an interface.");
242 cananian 1.8.2.1      assert checkLinker(in);
243 cananian 1.8.2.2      interfaces = Util.grow(HClass.arrayFactory,
244 cananian 1.8.2.2                             (HClass[]) interfaces, in, interfaces.length);
245 cananian 1.6.2.10     hasBeenModified = true;
246 cananian 1.1        }
247 cananian 1.6.2.10   public void removeInterface(HClass in) throws NoSuchClassException {
248 cananian 1.8.2.1      assert checkLinker(in);
249 cananian 1.2          for (int i=0; i<interfaces.length; i++) {
250 cananian 1.2            if (interfaces[i].equals(in)) {
251 cananian 1.8.2.2          interfaces = Util.shrink(HClass.arrayFactory,
252 cananian 1.8.2.2                                   (HClass[]) interfaces, i);
253 cananian 1.6.2.10         hasBeenModified = true;
254 cananian 1.2              return;
255 cananian 1.2            }
256 cananian 1.2          }
257 cananian 1.6.2.10     throw new NoSuchClassException(in.toString());
258 cananian 1.6        }
259 cananian 1.6        public void removeAllInterfaces() {
260 cananian 1.6.2.10     if (interfaces.length!=0) hasBeenModified = true;
261 cananian 1.6          // wheee.
262 cananian 1.6          interfaces = new HClass[0];
263 cananian 1.1        }
264 cananian 1.1      
265 cananian 1.1        /**
266 cananian 1.1         * Set the source file name for this class.
267 cananian 1.1         */
268 cananian 1.6.2.10   public void setSourceFile(String sf) {
269 cananian 1.6.2.10     if (!this.sourcefile.equals(sf)) hasBeenModified = true;
270 cananian 1.6.2.10     this.sourcefile = sf;
271 cananian 1.6.2.10   }
272 cananian 1.6.2.15 
273 cananian 1.6.2.15   //----------------------------------------------------------
274 cananian 1.6.2.15   // assertion helper.
275 cananian 1.6.2.15   private boolean checkLinker(HClass hc) {
276 cananian 1.6.2.15     return hc.isPrimitive() || hc.getLinker()==getLinker();
277 cananian 1.6.2.15   }
278 cananian 1.6.2.15   //----------------------------------------------------------
279 cananian 1.1      
280 cananian 1.6.2.5    /** Serializable interface. */
281 cananian 1.6.2.17   public Object writeReplace() {
282 cananian 1.6.2.18     return new Stub(this);
283 cananian 1.6.2.17   }
284 cananian 1.6.2.17   private static final class Stub implements java.io.Serializable {
285 cananian 1.6.2.17     private final Linker linker;
286 cananian 1.6.2.17     private final String name;
287 cananian 1.6.2.17     private final HClass superclass;
288 cananian 1.6.2.17     private final HClass[] interfaces;
289 cananian 1.6.2.17     private final int modifiers;
290 cananian 1.6.2.17     private final String sourcefile;
291 cananian 1.6.2.18     private final FieldStub[] declaredFields;
292 cananian 1.6.2.18     private final MethodStub[] declaredMethods;
293 cananian 1.6.2.17     private final boolean hasBeenModified;
294 cananian 1.6.2.17     Stub(HClassSyn c) { // store salient information
295 cananian 1.6.2.17       // using the method versions below allows up to resolve
296 cananian 1.6.2.17       // class name pointers.  note that we intern strings below.
297 cananian 1.6.2.17       this.linker = c.getLinker();
298 cananian 1.6.2.17       this.name = c.getName().intern();
299 cananian 1.6.2.17       this.superclass = c.getSuperclass();
300 cananian 1.6.2.17       this.interfaces = c.getInterfaces();
301 cananian 1.6.2.17       this.modifiers  = c.getModifiers();
302 cananian 1.6.2.17       this.sourcefile = c.getSourceFile().intern();
303 cananian 1.6.2.17       this.hasBeenModified = c.hasBeenModified();
304 cananian 1.6.2.18       // stub out fields and methods.
305 cananian 1.6.2.18       HField[] declf = c.getDeclaredFields();
306 cananian 1.6.2.18       this.declaredFields = new FieldStub[declf.length];
307 cananian 1.6.2.18       for (int i=0; i<declf.length; i++)
308 cananian 1.6.2.18         this.declaredFields[i] = new FieldStub(declf[i]);
309 cananian 1.6.2.18       HMethod[] declm = c.getDeclaredMethods();
310 cananian 1.6.2.18       this.declaredMethods= new MethodStub[declm.length];
311 cananian 1.6.2.18       for (int i=0; i<declm.length; i++)
312 cananian 1.6.2.18         this.declaredMethods[i] = new MethodStub(declm[i]);
313 cananian 1.6.2.17     }
314 cananian 1.6.2.18     public Object readResolve() throws java.io.ObjectStreamException {
315 cananian 1.6.2.18       HClassSyn c = new HClassSyn(linker, name, superclass, interfaces,
316 cananian 1.6.2.18                                   modifiers, sourcefile);
317 cananian 1.6.2.18       c.declaredFields = new HField[declaredFields.length];
318 cananian 1.6.2.18       for (int i=0; i<declaredFields.length; i++)
319 cananian 1.6.2.18         c.declaredFields[i] = declaredFields[i].reconstruct(c);
320 cananian 1.6.2.18       c.declaredMethods = new HMethod[declaredMethods.length];
321 cananian 1.6.2.18       for (int i=0; i<declaredMethods.length; i++)
322 cananian 1.6.2.18         c.declaredMethods[i] = declaredMethods[i].reconstruct(c);
323 cananian 1.6.2.18       // last because reconstruction twiddles the field.
324 cananian 1.6.2.18       c.hasBeenModified = this.hasBeenModified;
325 cananian 1.6.2.18       return c;
326 cananian 1.6.2.18     }
327 cananian 1.6.2.18   }
328 cananian 1.6.2.18   private static class MemberStub implements java.io.Serializable {
329 cananian 1.6.2.18     final String name;
330 cananian 1.6.2.18     final int modifiers;
331 cananian 1.6.2.18     final boolean isSynthetic;
332 cananian 1.6.2.18     MemberStub(HMember hm) {
333 cananian 1.6.2.18       this.name = hm.getName().intern();
334 cananian 1.6.2.18       this.modifiers = hm.getModifiers();
335 cananian 1.6.2.18       this.isSynthetic = hm.isSynthetic();
336 cananian 1.6.2.18     }
337 cananian 1.6.2.18   }
338 cananian 1.6.2.18   private static class FieldStub extends MemberStub {
339 cananian 1.6.2.18     final HPointer type;
340 cananian 1.6.2.18     final Object constValue;
341 cananian 1.6.2.18     FieldStub(HField hf) {
342 cananian 1.6.2.18       super(hf);
343 cananian 1.6.2.18       this.type = new ClassPointer(hf.getType());
344 cananian 1.6.2.18       this.constValue = hf.getConstant();
345 cananian 1.6.2.18     }
346 cananian 1.6.2.18     HFieldSyn reconstruct(HClassSyn parent) {
347 cananian 1.6.2.19       HFieldSyn hf = new HFieldSyn(parent, FieldStub.this.name, type);
348 cananian 1.6.2.18       HFieldMutator hfm = hf.getMutator();
349 cananian 1.6.2.19       hfm.setModifiers(FieldStub.this.modifiers);
350 cananian 1.6.2.18       hfm.setConstant(constValue);
351 cananian 1.6.2.18       hfm.setSynthetic(isSynthetic);
352 cananian 1.6.2.18       return hf;
353 cananian 1.6.2.18     }
354 cananian 1.6.2.18   }
355 cananian 1.6.2.18   static class MethodStub extends MemberStub {
356 cananian 1.6.2.18     final String descriptor;
357 cananian 1.6.2.18     final String[] parameterNames;
358 cananian 1.6.2.18     final HPointer[] exceptionTypes;
359 vivien   1.6.2.20     final boolean isConstructor;
360 vivien   1.6.2.20     final boolean isInitializer;
361 cananian 1.6.2.18     MethodStub(HMethod hm) {
362 cananian 1.6.2.18       super(hm);
363 vivien   1.6.2.20       this.isConstructor = hm instanceof HConstructor;
364 vivien   1.6.2.20       this.isInitializer = hm instanceof HInitializer;
365 cananian 1.6.2.18       this.descriptor = hm.getDescriptor().intern();
366 cananian 1.6.2.18       String[] pn = hm.getParameterNames();
367 cananian 1.6.2.18       this.parameterNames = new String[pn.length];
368 cananian 1.6.2.18       for (int i=0; i<pn.length; i++)
369 cananian 1.6.2.18         this.parameterNames[i] = (pn[i]==null) ? null : pn[i].intern();
370 cananian 1.6.2.18       HClass[] et = hm.getExceptionTypes();
371 cananian 1.6.2.18       this.exceptionTypes = new HPointer[et.length];
372 cananian 1.6.2.18       for (int i=0; i<et.length; i++)
373 cananian 1.6.2.18         this.exceptionTypes[i] = new ClassPointer(et[i]);
374 cananian 1.6.2.18     }
375 cananian 1.6.2.18     HMethodSyn reconstruct(HClassSyn parent) {
376 vivien   1.6.2.20       return reconstruct
377 vivien   1.6.2.20         (isInitializer ? new HInitializerSyn(parent):
378 vivien   1.6.2.20          isConstructor ? new HConstructorSyn(parent,descriptor):
379 vivien   1.6.2.20          new HMethodSyn(parent, MethodStub.this.name, descriptor));
380 cananian 1.6.2.18     }
381 cananian 1.6.2.18     HMethodSyn reconstruct(HClassArraySyn parent) {
382 cananian 1.6.2.19       return reconstruct(new HMethodSyn(parent, MethodStub.this.name, descriptor));
383 cananian 1.6.2.18     }
384 cananian 1.6.2.18     private HMethodSyn reconstruct(HMethodSyn hm) {
385 cananian 1.6.2.18       HMethodMutator hmm = hm.getMutator();
386 vivien   1.6.2.20       hmm.setModifiers(MethodStub.this.modifiers);
387 vivien   1.6.2.20       hmm.setSynthetic(isSynthetic);
388 cananian 1.6.2.18       hmm.setParameterNames(parameterNames);
389 cananian 1.6.2.18       // back door so that HPointer isn't resolved yet.
390 cananian 1.6.2.18       hm.exceptionTypes = this.exceptionTypes;
391 cananian 1.6.2.18       return hm;
392 cananian 1.6.2.17     }
393 cananian 1.6.2.5    }
394 cananian 1.1      }
395 cananian 1.1      // set emacs indentation style.
396 cananian 1.1      // Local Variables:
397 cananian 1.1      // c-basic-offset:2
398 cananian 1.1      // End: