001    package edu.rice.cs.cunit.subAnnot;
002    
003    import edu.rice.cs.cunit.classFile.ClassFile;
004    import edu.rice.cs.cunit.classFile.ClassFileTools;
005    import edu.rice.cs.cunit.classFile.FieldInfo;
006    import edu.rice.cs.cunit.classFile.attributes.RuntimeVisibleAnnotationsAttributeInfo;
007    
008    import java.io.IOException;
009    import java.lang.reflect.AnnotatedElement;
010    import java.lang.reflect.Field;
011    import java.lang.reflect.Type;
012    
013    /**
014     * Extended Field class to support annotations with subclassing.
015     *
016     * @author Mathias Ricken
017     */
018    public class FieldEx extends AAnnotatedElementEx {
019        /**
020         * The java.lang.reflect.Field object that represents the field.
021         */
022        public final Field java;
023    
024        /**
025         * Create an extended Field instance for the specified field.
026         * @param f field
027         */
028        public FieldEx(Field f) {
029            java = f;
030            findFieldAnnotationsAttributeInfo(f);
031        }
032    
033        /**
034         * Return the annotated element.
035         * @return annotated element
036         */
037        protected AnnotatedElement getAnnotatedElement() {
038            return java;
039        }
040    
041        /**
042         * Find the annotations attribute and assign it to the _ai field.
043         * @param field field whose annotations attribute should be found
044         */
045        protected void findFieldAnnotationsAttributeInfo(Field field) {
046            ClassFileTools.ClassLocation cl = ClassFileTools.findClassFile(field.getDeclaringClass().getName(), _classPath);
047            if (cl==null) {
048                setClassFileNotFound(true);
049                return;
050            }
051            ClassFile cf = cl.getClassFile();
052            try {
053                cl.close();
054            }
055            catch(IOException e) { /* ignore */ }
056            for(FieldInfo fi: cf.getFields()) {
057                if (fi.getName().toString().equals(field.getName())) {
058                    String pt = fi.getDescriptor().toString();
059                    String cpt = field.getType().getName();
060                    if ((pt.length()>0) && (pt.charAt(0)=='[') &&
061                        (cpt.length()>0) && (cpt.charAt(0)=='[')) {
062                        // if both type strings are arrays, cut off matching '[' prefixes
063                        do {
064                            pt = pt.substring(1);
065                            cpt = cpt.substring(1);
066                        } while ((pt.length()>0) && (pt.charAt(0)=='[') &&
067                                 (cpt.length()>0) && (cpt.charAt(0)=='['));
068                        // if this is an object array, the class name will be "Lxxx;"
069                        // cut off the 'L' and ';'
070                        if ((cpt.charAt(0)=='L') && (cpt.charAt(cpt.length()-1)==';')) {
071                            cpt = cpt.substring(1,cpt.length()-1);
072                        }
073                    }
074                    if (ClassFileTools.getTypeString(pt,"").equals(cpt+" ")) {
075                        _ai = new RuntimeVisibleAnnotationsAttributeInfo[1];
076                        _ai[0] = (RuntimeVisibleAnnotationsAttributeInfo)
077                            cf.getAttribute(RuntimeVisibleAnnotationsAttributeInfo.getAttributeName());
078                        return;
079                    }
080                }
081            }
082            throw new ClassFormatError("Could not find field "+ field +" in class files");
083        }
084    
085        /**
086         * Returns the name of the field represented by this <code>Field</code> object.
087         * @return name
088         */
089        public String getName() {
090            return java.getName();
091        }
092    
093        /**
094         * Returns the Java language modifiers for the field represented by this <code>Field</code> object, as an integer.
095         * The <code>Modifier</code> class should be used to decode the modifiers.
096         * @return modifiers
097         * @see java.lang.reflect.Modifier
098         */
099        public int getModifiers() {
100            return java.getModifiers();
101        }
102    
103        /**
104         * Returns <tt>true</tt> if this field represents an element of an enumerated type; returns <tt>false</tt>
105         * otherwise.
106         *
107         * @return <tt>true</tt> if and only if this field represents an element of an enumerated type.
108         *
109         * @since 1.5
110         */
111        public boolean isEnumConstant() {
112            return java.isEnumConstant();
113        }
114    
115        /**
116         * Returns <tt>true</tt> if this field is a synthetic field; returns <tt>false</tt> otherwise.
117         *
118         * @return true if and only if this field is a synthetic field as defined by the Java Language Specification.
119         *
120         * @since 1.5
121         */
122        public boolean isSynthetic() {
123            return java.isSynthetic();
124        }
125    
126        /**
127         * Returns a <code>Class</code> object that identifies the declared type for the field represented by this
128         * <code>Field</code> object.
129         *
130         * @return a <code>Class</code> object identifying the declared type of the field represented by this object
131         */
132        public Class<?> getType() {
133            return java.getType();
134        }
135    
136        /**
137         * Returns a <tt>Type</tt> object that represents the declared type for the field represented by this <tt>Field</tt>
138         * object.
139         * <p/>
140         * <p>If the <tt>Type</tt> is a parameterized type, the <tt>Type</tt> object returned must accurately reflect the
141         * actual type parameters used in the source code.
142         * <p/>
143         * <p>If an the  type of the underlying field is a type variable or a parameterized type, it is created. Otherwise,
144         * it is resolved.
145         *
146         * @return a <tt>Type</tt> object that represents the declared type for the field represented by this <tt>Field</tt>
147         *         object
148         *
149         * @throws java.lang.reflect.GenericSignatureFormatError
150         *                                 if the generic field signature does not conform to the format specified in the
151         *                                 Java Virtual Machine Specification, 3rd edition
152         * @throws TypeNotPresentException if the generic type signature of the underlying field refers to a non-existent
153         *                                 type declaration
154         * @throws java.lang.reflect.MalformedParameterizedTypeException
155         *                                 if the generic signature of the underlying field refers to a parameterized type
156         *                                 that cannot be instantiated for any reason
157         * @since 1.5
158         */
159        public Type getGenericType() {
160            return java.getGenericType();
161        }
162    
163        /**
164         * Compares this <code>Field</code> against the specified object.  Returns true if the objects are the same.  Two
165         * <code>Field</code> objects are the same if they were declared by the same class and have the same name and type.
166         */
167        public boolean equals(Object obj) {
168            return (obj!=null)&&(obj.getClass().equals(this.getClass()) && (java.equals(obj)));
169        }
170    
171        /**
172         * Returns a hashcode for this <code>Field</code>.  This is computed as the exclusive-or of the hashcodes for the
173         * underlying field's declaring class name and its name.
174         */
175        public int hashCode() {
176            return java.hashCode();
177        }
178    
179        /**
180         * Returns a string describing this <code>Field</code>.  The format is the access modifiers for the field, if any,
181         * followed by the field type, followed by a space, followed by the fully-qualified name of the class declaring the
182         * field, followed by a period, followed by the name of the field. For example:
183         * <pre>
184         *    public static final int java.lang.Thread.MIN_PRIORITY
185         *    private int java.io.FileDescriptor.fd
186         * </pre>
187         * <p/>
188         * <p>The modifiers are placed in canonical order as specified by "The Java Language Specification".  This is
189         * <tt>public</tt>, <tt>protected</tt> or <tt>private</tt> first, and then other modifiers in the following order:
190         * <tt>static</tt>, <tt>final</tt>, <tt>transient</tt>, <tt>volatile</tt>.
191         */
192        public String toString() {
193            return java.toString();
194        }
195    
196        /**
197         * Returns a string describing this <code>Field</code>, including its generic type.  The format is the access
198         * modifiers for the field, if any, followed by the generic field type, followed by a space, followed by the
199         * fully-qualified name of the class declaring the field, followed by a period, followed by the name of the field.
200         * <p/>
201         * <p>The modifiers are placed in canonical order as specified by "The Java Language Specification".  This is
202         * <tt>public</tt>, <tt>protected</tt> or <tt>private</tt> first, and then other modifiers in the following order:
203         * <tt>static</tt>, <tt>final</tt>, <tt>transient</tt>, <tt>volatile</tt>.
204         *
205         * @return a string describing this <code>Field</code>, including its generic type
206         *
207         * @since 1.5
208         */
209        public String toGenericString() {
210            return java.toGenericString();
211        }
212    
213        /**
214         * Returns the value of the field represented by this <code>Field</code>, on the specified object. The value is
215         * automatically wrapped in an object if it has a primitive type.
216         * <p/>
217         * <p>The underlying field's value is obtained as follows:
218         * <p/>
219         * <p>If the underlying field is a static field, the <code>obj</code> argument is ignored; it may be null.
220         * <p/>
221         * <p>Otherwise, the underlying field is an instance field.  If the specified <code>obj</code> argument is null, the
222         * method throws a <code>NullPointerException.</code> If the specified object is not an instance of the class or
223         * interface declaring the underlying field, the method throws an <code>IllegalArgumentException</code>.
224         * <p/>
225         * <p>If this <code>Field</code> object enforces Java language access control, and the underlying field is
226         * inaccessible, the method throws an <code>IllegalAccessException</code>. If the underlying field is static, the
227         * class that declared the field is initialized if it has not already been initialized.
228         * <p/>
229         * <p>Otherwise, the value is retrieved from the underlying instance or static field.  If the field has a primitive
230         * type, the value is wrapped in an object before being returned, otherwise it is returned as is.
231         * <p/>
232         * <p>If the field is hidden in the type of <code>obj</code>, the field's value is obtained according to the
233         * preceding rules.
234         *
235         * @param obj object from which the represented field's value is to be extracted
236         *
237         * @return the value of the represented field in object <tt>obj</tt>; primitive values are wrapped in an appropriate
238         *         object before being returned
239         *
240         * @throws IllegalAccessException      if the underlying field is inaccessible.
241         * @throws IllegalArgumentException    if the specified object is not an instance of the class or interface
242         *                                     declaring the underlying field (or a subclass or implementor thereof).
243         * @throws NullPointerException        if the specified object is null and the field is an instance field.
244         * @throws ExceptionInInitializerError if the initialization provoked by this method fails.
245         */
246        public Object get(Object obj) throws IllegalArgumentException, IllegalAccessException {
247            return java.get(obj);
248        }
249    
250        /**
251         * Gets the value of a static or instance <code>boolean</code> field.
252         *
253         * @param obj the object to extract the <code>boolean</code> value from
254         *
255         * @return the value of the <code>boolean</code> field
256         *
257         * @throws IllegalAccessException      if the underlying field is inaccessible.
258         * @throws IllegalArgumentException    if the specified object is not an instance of the class or interface
259         *                                     declaring the underlying field (or a subclass or implementor thereof), or if
260         *                                     the field value cannot be converted to the type <code>boolean</code> by a
261         *                                     widening conversion.
262         * @throws NullPointerException        if the specified object is null and the field is an instance field.
263         * @throws ExceptionInInitializerError if the initialization provoked by this method fails.
264         * @see java.lang.reflect.Field#get
265         */
266        public boolean getBoolean(Object obj) throws IllegalArgumentException, IllegalAccessException {
267            return java.getBoolean(obj);
268        }
269    
270        /**
271         * Gets the value of a static or instance <code>byte</code> field.
272         *
273         * @param obj the object to extract the <code>byte</code> value from
274         *
275         * @return the value of the <code>byte</code> field
276         *
277         * @throws IllegalAccessException      if the underlying field is inaccessible.
278         * @throws IllegalArgumentException    if the specified object is not an instance of the class or interface
279         *                                     declaring the underlying field (or a subclass or implementor thereof), or if
280         *                                     the field value cannot be converted to the type <code>byte</code> by a
281         *                                     widening conversion.
282         * @throws NullPointerException        if the specified object is null and the field is an instance field.
283         * @throws ExceptionInInitializerError if the initialization provoked by this method fails.
284         * @see java.lang.reflect.Field#get
285         */
286        public byte getByte(Object obj) throws IllegalArgumentException, IllegalAccessException {
287            return java.getByte(obj);
288        }
289    
290        /**
291         * Gets the value of a static or instance field of type <code>char</code> or of another primitive type convertible
292         * to type <code>char</code> via a widening conversion.
293         *
294         * @param obj the object to extract the <code>char</code> value from
295         *
296         * @return the value of the field converted to type <code>char</code>
297         *
298         * @throws IllegalAccessException      if the underlying field is inaccessible.
299         * @throws IllegalArgumentException    if the specified object is not an instance of the class or interface
300         *                                     declaring the underlying field (or a subclass or implementor thereof), or if
301         *                                     the field value cannot be converted to the type <code>char</code> by a
302         *                                     widening conversion.
303         * @throws NullPointerException        if the specified object is null and the field is an instance field.
304         * @throws ExceptionInInitializerError if the initialization provoked by this method fails.
305         * @see java.lang.reflect.Field#get
306         */
307        public char getChar(Object obj) throws IllegalArgumentException, IllegalAccessException {
308            return java.getChar(obj);
309        }
310    
311        /**
312         * Gets the value of a static or instance field of type <code>short</code> or of another primitive type convertible
313         * to type <code>short</code> via a widening conversion.
314         *
315         * @param obj the object to extract the <code>short</code> value from
316         *
317         * @return the value of the field converted to type <code>short</code>
318         *
319         * @throws IllegalAccessException      if the underlying field is inaccessible.
320         * @throws IllegalArgumentException    if the specified object is not an instance of the class or interface
321         *                                     declaring the underlying field (or a subclass or implementor thereof), or if
322         *                                     the field value cannot be converted to the type <code>short</code> by a
323         *                                     widening conversion.
324         * @throws NullPointerException        if the specified object is null and the field is an instance field.
325         * @throws ExceptionInInitializerError if the initialization provoked by this method fails.
326         * @see java.lang.reflect.Field#get
327         */
328        public short getShort(Object obj) throws IllegalArgumentException, IllegalAccessException {
329            return java.getShort(obj);
330        }
331    
332        /**
333         * Gets the value of a static or instance field of type <code>int</code> or of another primitive type convertible to
334         * type <code>int</code> via a widening conversion.
335         *
336         * @param obj the object to extract the <code>int</code> value from
337         *
338         * @return the value of the field converted to type <code>int</code>
339         *
340         * @throws IllegalAccessException      if the underlying field is inaccessible.
341         * @throws IllegalArgumentException    if the specified object is not an instance of the class or interface
342         *                                     declaring the underlying field (or a subclass or implementor thereof), or if
343         *                                     the field value cannot be converted to the type <code>int</code> by a
344         *                                     widening conversion.
345         * @throws NullPointerException        if the specified object is null and the field is an instance field.
346         * @throws ExceptionInInitializerError if the initialization provoked by this method fails.
347         * @see java.lang.reflect.Field#get
348         */
349        public int getInt(Object obj) throws IllegalArgumentException, IllegalAccessException {
350            return java.getInt(obj);
351        }
352    
353        /**
354         * Gets the value of a static or instance field of type <code>long</code> or of another primitive type convertible
355         * to type <code>long</code> via a widening conversion.
356         *
357         * @param obj the object to extract the <code>long</code> value from
358         *
359         * @return the value of the field converted to type <code>long</code>
360         *
361         * @throws IllegalAccessException      if the underlying field is inaccessible.
362         * @throws IllegalArgumentException    if the specified object is not an instance of the class or interface
363         *                                     declaring the underlying field (or a subclass or implementor thereof), or if
364         *                                     the field value cannot be converted to the type <code>long</code> by a
365         *                                     widening conversion.
366         * @throws NullPointerException        if the specified object is null and the field is an instance field.
367         * @throws ExceptionInInitializerError if the initialization provoked by this method fails.
368         * @see java.lang.reflect.Field#get
369         */
370        public long getLong(Object obj) throws IllegalArgumentException, IllegalAccessException {
371            return java.getLong(obj);
372        }
373    
374        /**
375         * Gets the value of a static or instance field of type <code>float</code> or of another primitive type convertible
376         * to type <code>float</code> via a widening conversion.
377         *
378         * @param obj the object to extract the <code>float</code> value from
379         *
380         * @return the value of the field converted to type <code>float</code>
381         *
382         * @throws IllegalAccessException      if the underlying field is inaccessible.
383         * @throws IllegalArgumentException    if the specified object is not an instance of the class or interface
384         *                                     declaring the underlying field (or a subclass or implementor thereof), or if
385         *                                     the field value cannot be converted to the type <code>float</code> by a
386         *                                     widening conversion.
387         * @throws NullPointerException        if the specified object is null and the field is an instance field.
388         * @throws ExceptionInInitializerError if the initialization provoked by this method fails.
389         * @see java.lang.reflect.Field#get
390         */
391        public float getFloat(Object obj) throws IllegalArgumentException, IllegalAccessException {
392            return java.getFloat(obj);
393        }
394    
395        /**
396         * Gets the value of a static or instance field of type <code>double</code> or of another primitive type convertible
397         * to type <code>double</code> via a widening conversion.
398         *
399         * @param obj the object to extract the <code>double</code> value from
400         *
401         * @return the value of the field converted to type <code>double</code>
402         *
403         * @throws IllegalAccessException      if the underlying field is inaccessible.
404         * @throws IllegalArgumentException    if the specified object is not an instance of the class or interface
405         *                                     declaring the underlying field (or a subclass or implementor thereof), or if
406         *                                     the field value cannot be converted to the type <code>double</code> by a
407         *                                     widening conversion.
408         * @throws NullPointerException        if the specified object is null and the field is an instance field.
409         * @throws ExceptionInInitializerError if the initialization provoked by this method fails.
410         * @see java.lang.reflect.Field#get
411         */
412        public double getDouble(Object obj) throws IllegalArgumentException, IllegalAccessException {
413            return java.getDouble(obj);
414        }
415    
416        /**
417         * Sets the field represented by this <code>Field</code> object on the specified object argument to the specified
418         * new value. The new value is automatically unwrapped if the underlying field has a primitive type.
419         * <p/>
420         * <p>The operation proceeds as follows:
421         * <p/>
422         * <p>If the underlying field is static, the <code>obj</code> argument is ignored; it may be null.
423         * <p/>
424         * <p>Otherwise the underlying field is an instance field.  If the specified object argument is null, the method
425         * throws a <code>NullPointerException</code>.  If the specified object argument is not an instance of the class or
426         * interface declaring the underlying field, the method throws an <code>IllegalArgumentException</code>.
427         * <p/>
428         * <p>If this <code>Field</code> object enforces Java language access control, and the underlying field is
429         * inaccessible, the method throws an <code>IllegalAccessException</code>.
430         * <p/>
431         * <p>If the underlying field is final, the method throws an <code>IllegalAccessException</code> unless
432         * <code>setAccessible(true)</code> has succeeded for this field and this field is non-static. Setting a final field
433         * in this way is meaningful only during deserialization or reconstruction of instances of classes with blank final
434         * fields, before they are made available for access by other parts of a program. Use in any other context may have
435         * unpredictable effects, including cases in which other parts of a program continue to use the original value of
436         * this field.
437         * <p/>
438         * <p>If the underlying field is of a primitive type, an unwrapping conversion is attempted to convert the new value
439         * to a value of a primitive type.  If this attempt fails, the method throws an
440         * <code>IllegalArgumentException</code>.
441         * <p/>
442         * <p>If, after possible unwrapping, the new value cannot be converted to the type of the underlying field by an
443         * identity or widening conversion, the method throws an <code>IllegalArgumentException</code>.
444         * <p/>
445         * <p>If the underlying field is static, the class that declared the field is initialized if it has not already been
446         * initialized.
447         * <p/>
448         * <p>The field is set to the possibly unwrapped and widened new value.
449         * <p/>
450         * <p>If the field is hidden in the type of <code>obj</code>, the field's value is set according to the preceding
451         * rules.
452         *
453         * @param obj   the object whose field should be modified
454         * @param value the new value for the field of <code>obj</code> being modified
455         *
456         * @throws IllegalAccessException      if the underlying field is inaccessible.
457         * @throws IllegalArgumentException    if the specified object is not an instance of the class or interface
458         *                                     declaring the underlying field (or a subclass or implementor thereof), or if
459         *                                     an unwrapping conversion fails.
460         * @throws NullPointerException        if the specified object is null and the field is an instance field.
461         * @throws ExceptionInInitializerError if the initialization provoked by this method fails.
462         */
463        public void set(Object obj, Object value) throws IllegalArgumentException, IllegalAccessException {
464            java.set(obj, value);
465        }
466    
467        /**
468         * Sets the value of a field as a <code>boolean</code> on the specified object. This method is equivalent to
469         * <code>set(obj, zObj)</code>, where <code>zObj</code> is a <code>Boolean</code> object and
470         * <code>zObj.booleanValue() == z</code>.
471         *
472         * @param obj the object whose field should be modified
473         * @param z   the new value for the field of <code>obj</code> being modified
474         *
475         * @throws IllegalAccessException      if the underlying field is inaccessible.
476         * @throws IllegalArgumentException    if the specified object is not an instance of the class or interface
477         *                                     declaring the underlying field (or a subclass or implementor thereof), or if
478         *                                     an unwrapping conversion fails.
479         * @throws NullPointerException        if the specified object is null and the field is an instance field.
480         * @throws ExceptionInInitializerError if the initialization provoked by this method fails.
481         * @see java.lang.reflect.Field#set
482         */
483        public void setBoolean(Object obj, boolean z) throws IllegalArgumentException, IllegalAccessException {
484            java.setBoolean(obj, z);
485        }
486    
487        /**
488         * Sets the value of a field as a <code>byte</code> on the specified object. This method is equivalent to
489         * <code>set(obj, bObj)</code>, where <code>bObj</code> is a <code>Byte</code> object and <code>bObj.byteValue() ==
490         * b</code>.
491         *
492         * @param obj the object whose field should be modified
493         * @param b   the new value for the field of <code>obj</code> being modified
494         *
495         * @throws IllegalAccessException      if the underlying field is inaccessible.
496         * @throws IllegalArgumentException    if the specified object is not an instance of the class or interface
497         *                                     declaring the underlying field (or a subclass or implementor thereof), or if
498         *                                     an unwrapping conversion fails.
499         * @throws NullPointerException        if the specified object is null and the field is an instance field.
500         * @throws ExceptionInInitializerError if the initialization provoked by this method fails.
501         * @see java.lang.reflect.Field#set
502         */
503        public void setByte(Object obj, byte b) throws IllegalArgumentException, IllegalAccessException {
504            java.setByte(obj, b);
505        }
506    
507        /**
508         * Sets the value of a field as a <code>char</code> on the specified object. This method is equivalent to
509         * <code>set(obj, cObj)</code>, where <code>cObj</code> is a <code>Character</code> object and
510         * <code>cObj.charValue() == c</code>.
511         *
512         * @param obj the object whose field should be modified
513         * @param c   the new value for the field of <code>obj</code> being modified
514         *
515         * @throws IllegalAccessException      if the underlying field is inaccessible.
516         * @throws IllegalArgumentException    if the specified object is not an instance of the class or interface
517         *                                     declaring the underlying field (or a subclass or implementor thereof), or if
518         *                                     an unwrapping conversion fails.
519         * @throws NullPointerException        if the specified object is null and the field is an instance field.
520         * @throws ExceptionInInitializerError if the initialization provoked by this method fails.
521         * @see java.lang.reflect.Field#set
522         */
523        public void setChar(Object obj, char c) throws IllegalArgumentException, IllegalAccessException {
524            java.setChar(obj, c);
525        }
526    
527        /**
528         * Sets the value of a field as a <code>short</code> on the specified object. This method is equivalent to
529         * <code>set(obj, sObj)</code>, where <code>sObj</code> is a <code>Short</code> object and <code>sObj.shortValue()
530         * == s</code>.
531         *
532         * @param obj the object whose field should be modified
533         * @param s   the new value for the field of <code>obj</code> being modified
534         *
535         * @throws IllegalAccessException      if the underlying field is inaccessible.
536         * @throws IllegalArgumentException    if the specified object is not an instance of the class or interface
537         *                                     declaring the underlying field (or a subclass or implementor thereof), or if
538         *                                     an unwrapping conversion fails.
539         * @throws NullPointerException        if the specified object is null and the field is an instance field.
540         * @throws ExceptionInInitializerError if the initialization provoked by this method fails.
541         * @see java.lang.reflect.Field#set
542         */
543        public void setShort(Object obj, short s) throws IllegalArgumentException, IllegalAccessException {
544            java.setShort(obj, s);
545        }
546    
547        /**
548         * Sets the value of a field as an <code>int</code> on the specified object. This method is equivalent to
549         * <code>set(obj, iObj)</code>, where <code>iObj</code> is a <code>Integer</code> object and <code>iObj.intValue()
550         * == i</code>.
551         *
552         * @param obj the object whose field should be modified
553         * @param i   the new value for the field of <code>obj</code> being modified
554         *
555         * @throws IllegalAccessException      if the underlying field is inaccessible.
556         * @throws IllegalArgumentException    if the specified object is not an instance of the class or interface
557         *                                     declaring the underlying field (or a subclass or implementor thereof), or if
558         *                                     an unwrapping conversion fails.
559         * @throws NullPointerException        if the specified object is null and the field is an instance field.
560         * @throws ExceptionInInitializerError if the initialization provoked by this method fails.
561         * @see java.lang.reflect.Field#set
562         */
563        public void setInt(Object obj, int i) throws IllegalArgumentException, IllegalAccessException {
564            java.setInt(obj, i);
565        }
566    
567        /**
568         * Sets the value of a field as a <code>long</code> on the specified object. This method is equivalent to
569         * <code>set(obj, lObj)</code>, where <code>lObj</code> is a <code>Long</code> object and <code>lObj.longValue() ==
570         * l</code>.
571         *
572         * @param obj the object whose field should be modified
573         * @param l   the new value for the field of <code>obj</code> being modified
574         *
575         * @throws IllegalAccessException      if the underlying field is inaccessible.
576         * @throws IllegalArgumentException    if the specified object is not an instance of the class or interface
577         *                                     declaring the underlying field (or a subclass or implementor thereof), or if
578         *                                     an unwrapping conversion fails.
579         * @throws NullPointerException        if the specified object is null and the field is an instance field.
580         * @throws ExceptionInInitializerError if the initialization provoked by this method fails.
581         * @see java.lang.reflect.Field#set
582         */
583        public void setLong(Object obj, long l) throws IllegalArgumentException, IllegalAccessException {
584            java.setLong(obj, l);
585        }
586    
587        /**
588         * Sets the value of a field as a <code>float</code> on the specified object. This method is equivalent to
589         * <code>set(obj, fObj)</code>, where <code>fObj</code> is a <code>Float</code> object and <code>fObj.floatValue()
590         * == f</code>.
591         *
592         * @param obj the object whose field should be modified
593         * @param f   the new value for the field of <code>obj</code> being modified
594         *
595         * @throws IllegalAccessException      if the underlying field is inaccessible.
596         * @throws IllegalArgumentException    if the specified object is not an instance of the class or interface
597         *                                     declaring the underlying field (or a subclass or implementor thereof), or if
598         *                                     an unwrapping conversion fails.
599         * @throws NullPointerException        if the specified object is null and the field is an instance field.
600         * @throws ExceptionInInitializerError if the initialization provoked by this method fails.
601         * @see java.lang.reflect.Field#set
602         */
603        public void setFloat(Object obj, float f) throws IllegalArgumentException, IllegalAccessException {
604            java.setFloat(obj, f);
605        }
606    
607        /**
608         * Sets the value of a field as a <code>double</code> on the specified object. This method is equivalent to
609         * <code>set(obj, dObj)</code>, where <code>dObj</code> is a <code>Double</code> object and <code>dObj.doubleValue()
610         * == d</code>.
611         *
612         * @param obj the object whose field should be modified
613         * @param d   the new value for the field of <code>obj</code> being modified
614         *
615         * @throws IllegalAccessException      if the underlying field is inaccessible.
616         * @throws IllegalArgumentException    if the specified object is not an instance of the class or interface
617         *                                     declaring the underlying field (or a subclass or implementor thereof), or if
618         *                                     an unwrapping conversion fails.
619         * @throws NullPointerException        if the specified object is null and the field is an instance field.
620         * @throws ExceptionInInitializerError if the initialization provoked by this method fails.
621         * @see java.lang.reflect.Field#set
622         */
623        public void setDouble(Object obj, double d) throws IllegalArgumentException, IllegalAccessException {
624            java.setDouble(obj, d);
625        }
626    }