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