1 /*
   2  * Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package java.lang.reflect;
  27 
  28 import jdk.internal.access.SharedSecrets;
  29 import jdk.internal.reflect.CallerSensitive;
  30 import jdk.internal.reflect.FieldAccessor;
  31 import jdk.internal.reflect.Reflection;
  32 import jdk.internal.vm.annotation.ForceInline;
  33 import jdk.internal.vm.annotation.Stable;
  34 import sun.reflect.generics.repository.FieldRepository;
  35 import sun.reflect.generics.factory.CoreReflectionFactory;
  36 import sun.reflect.generics.factory.GenericsFactory;
  37 import sun.reflect.generics.scope.ClassScope;
  38 import java.lang.annotation.Annotation;
  39 import java.util.Map;
  40 import java.util.Objects;
  41 import sun.reflect.annotation.AnnotationParser;
  42 import sun.reflect.annotation.AnnotationSupport;
  43 import sun.reflect.annotation.TypeAnnotation;
  44 import sun.reflect.annotation.TypeAnnotationParser;
  45 
  46 /**
  47  * A {@code Field} provides information about, and dynamic access to, a
  48  * single field of a class or an interface.  The reflected field may
  49  * be a class (static) field or an instance field.
  50  *
  51  * <p>A {@code Field} permits widening conversions to occur during a get or
  52  * set access operation, but throws an {@code IllegalArgumentException} if a
  53  * narrowing conversion would occur.
  54  *
  55  * @see Member
  56  * @see java.lang.Class
  57  * @see java.lang.Class#getFields()
  58  * @see java.lang.Class#getField(String)
  59  * @see java.lang.Class#getDeclaredFields()
  60  * @see java.lang.Class#getDeclaredField(String)
  61  *
  62  * @author Kenneth Russell
  63  * @author Nakul Saraiya
  64  * @since 1.1
  65  */
  66 public final
  67 class Field extends AccessibleObject implements Member {
  68 
  69     @Stable
  70     private Class<?>            clazz;
  71     private int                 slot;
  72     // This is guaranteed to be interned by the VM in the 1.4
  73     // reflection implementation
  74     private String              name;
  75     @Stable
  76     private Class<?>            type;
  77     @Stable
  78     private int                 modifiers;
  79     private boolean             trustedFinal;
  80     // Generics and annotations support
  81     private transient String    signature;
  82     // generic info repository; lazily initialized
  83     private transient FieldRepository genericInfo;
  84     private byte[]              annotations;
  85     // Cached field accessor created without override
  86     @Stable
  87     private FieldAccessor fieldAccessor;
  88     // Cached field accessor created with override
  89     @Stable
  90     private FieldAccessor overrideFieldAccessor;
  91     // For sharing of FieldAccessors. This branching structure is
  92     // currently only two levels deep (i.e., one root Field and
  93     // potentially many Field objects pointing to it.)
  94     //
  95     // If this branching structure would ever contain cycles, deadlocks can
  96     // occur in annotation code.
  97     private Field               root;
  98 
  99     // Generics infrastructure
 100 
 101     private String getGenericSignature() {return signature;}
 102 
 103     // Accessor for factory
 104     private GenericsFactory getFactory() {
 105         Class<?> c = getDeclaringClass();
 106         // create scope and factory
 107         return CoreReflectionFactory.make(c, ClassScope.make(c));
 108     }
 109 
 110     // Accessor for generic info repository
 111     private FieldRepository getGenericInfo() {
 112         // lazily initialize repository if necessary
 113         if (genericInfo == null) {
 114             // create and cache generic info repository
 115             genericInfo = FieldRepository.make(getGenericSignature(),
 116                                                getFactory());
 117         }
 118         return genericInfo; //return cached repository
 119     }
 120 
 121 
 122     /**
 123      * Package-private constructor
 124      */
 125     @SuppressWarnings("deprecation")
 126     Field(Class<?> declaringClass,
 127           String name,
 128           Class<?> type,
 129           int modifiers,
 130           boolean trustedFinal,
 131           int slot,
 132           String signature,
 133           byte[] annotations)
 134     {
 135         this.clazz = declaringClass;
 136         this.name = name;
 137         this.type = type;
 138         this.modifiers = modifiers;
 139         this.trustedFinal = trustedFinal;
 140         this.slot = slot;
 141         this.signature = signature;
 142         this.annotations = annotations;
 143     }
 144 
 145     /**
 146      * Package-private routine (exposed to java.lang.Class via
 147      * ReflectAccess) which returns a copy of this Field. The copy's
 148      * "root" field points to this Field.
 149      */
 150     Field copy() {
 151         // This routine enables sharing of FieldAccessor objects
 152         // among Field objects which refer to the same underlying
 153         // method in the VM. (All of this contortion is only necessary
 154         // because of the "accessibility" bit in AccessibleObject,
 155         // which implicitly requires that new java.lang.reflect
 156         // objects be fabricated for each reflective call on Class
 157         // objects.)
 158         if (this.root != null)
 159             throw new IllegalArgumentException("Can not copy a non-root Field");
 160 
 161         Field res = new Field(clazz, name, type, modifiers, trustedFinal, slot, signature, annotations);
 162         res.root = this;
 163         // Might as well eagerly propagate this if already present
 164         res.fieldAccessor = fieldAccessor;
 165         res.overrideFieldAccessor = overrideFieldAccessor;
 166 
 167         return res;
 168     }
 169 
 170     /**
 171      * @throws InaccessibleObjectException {@inheritDoc}
 172      * @throws SecurityException {@inheritDoc}
 173      */
 174     @Override
 175     @CallerSensitive
 176     public void setAccessible(boolean flag) {
 177         AccessibleObject.checkPermission();
 178         if (flag) checkCanSetAccessible(Reflection.getCallerClass());
 179         setAccessible0(flag);
 180     }
 181 
 182     @Override
 183     void checkCanSetAccessible(Class<?> caller) {
 184         checkCanSetAccessible(caller, clazz);
 185     }
 186 
 187     /**
 188      * Returns the {@code Class} object representing the class or interface
 189      * that declares the field represented by this {@code Field} object.
 190      */
 191     @Override
 192     public Class<?> getDeclaringClass() {
 193         return clazz;
 194     }
 195 
 196     /**
 197      * Returns the name of the field represented by this {@code Field} object.
 198      */
 199     public String getName() {
 200         return name;
 201     }
 202 
 203     /**
 204      * Returns the Java language modifiers for the field represented
 205      * by this {@code Field} object, as an integer. The {@code Modifier} class should
 206      * be used to decode the modifiers.
 207      *
 208      * @see Modifier
 209      * @jls 8.3 Field Declarations
 210      * @jls 9.3 Field (Constant) Declarations
 211      */
 212     public int getModifiers() {
 213         return modifiers;
 214     }
 215 
 216     /**
 217      * Returns {@code true} if this field represents an element of
 218      * an enumerated class; returns {@code false} otherwise.
 219      *
 220      * @return {@code true} if and only if this field represents an element of
 221      * an enumerated class.
 222      * @since 1.5
 223      * @jls 8.9.1 Enum Constants
 224      */
 225     public boolean isEnumConstant() {
 226         return (getModifiers() & Modifier.ENUM) != 0;
 227     }
 228 
 229     /**
 230      * Returns {@code true} if this field is a synthetic
 231      * field; returns {@code false} otherwise.
 232      *
 233      * @return true if and only if this field is a synthetic
 234      * field as defined by the Java Language Specification.
 235      * @since 1.5
 236      * @see <a
 237      * href="{@docRoot}/java.base/java/lang/reflect/package-summary.html#LanguageJvmModel">Java
 238      * programming language and JVM modeling in core reflection</a>
 239      */
 240     public boolean isSynthetic() {
 241         return Modifier.isSynthetic(getModifiers());
 242     }
 243 
 244     /**
 245      * Returns a {@code Class} object that identifies the
 246      * declared type for the field represented by this
 247      * {@code Field} object.
 248      *
 249      * @return a {@code Class} object identifying the declared
 250      * type of the field represented by this object
 251      */
 252     public Class<?> getType() {
 253         return type;
 254     }
 255 
 256     /**
 257      * Returns a {@code Type} object that represents the declared type for
 258      * the field represented by this {@code Field} object.
 259      *
 260      * <p>If the declared type of the field is a parameterized type,
 261      * the {@code Type} object returned must accurately reflect the
 262      * actual type arguments used in the source code.
 263      *
 264      * <p>If the type of the underlying field is a type variable or a
 265      * parameterized type, it is created. Otherwise, it is resolved.
 266      *
 267      * @return a {@code Type} object that represents the declared type for
 268      *     the field represented by this {@code Field} object
 269      * @throws GenericSignatureFormatError if the generic field
 270      *     signature does not conform to the format specified in
 271      *     <cite>The Java Virtual Machine Specification</cite>
 272      * @throws TypeNotPresentException if the generic type
 273      *     signature of the underlying field refers to a non-existent
 274      *     class or interface declaration
 275      * @throws MalformedParameterizedTypeException if the generic
 276      *     signature of the underlying field refers to a parameterized type
 277      *     that cannot be instantiated for any reason
 278      * @since 1.5
 279      */
 280     public Type getGenericType() {
 281         if (getGenericSignature() != null)
 282             return getGenericInfo().getGenericType();
 283         else
 284             return getType();
 285     }
 286 
 287 
 288     /**
 289      * Compares this {@code Field} against the specified object.  Returns
 290      * true if the objects are the same.  Two {@code Field} objects are the same if
 291      * they were declared by the same class and have the same name
 292      * and type.
 293      */
 294     public boolean equals(Object obj) {
 295         if (obj instanceof Field other) {
 296             return (getDeclaringClass() == other.getDeclaringClass())
 297                 && (getName() == other.getName())
 298                 && (getType() == other.getType());
 299         }
 300         return false;
 301     }
 302 
 303     /**
 304      * Returns a hashcode for this {@code Field}.  This is computed as the
 305      * exclusive-or of the hashcodes for the underlying field's
 306      * declaring class name and its name.
 307      */
 308     public int hashCode() {
 309         return getDeclaringClass().getName().hashCode() ^ getName().hashCode();
 310     }
 311 
 312     /**
 313      * Returns a string describing this {@code Field}.  The format is
 314      * the access modifiers for the field, if any, followed
 315      * by the field type, followed by a space, followed by
 316      * the fully-qualified name of the class declaring the field,
 317      * followed by a period, followed by the name of the field.
 318      * For example:
 319      * <pre>
 320      *    public static final int java.lang.Thread.MIN_PRIORITY
 321      *    private int java.io.FileDescriptor.fd
 322      * </pre>
 323      *
 324      * <p>The modifiers are placed in canonical order as specified by
 325      * "The Java Language Specification".  This is {@code public},
 326      * {@code protected} or {@code private} first, and then other
 327      * modifiers in the following order: {@code static}, {@code final},
 328      * {@code transient}, {@code volatile}.
 329      *
 330      * @return a string describing this {@code Field}
 331      * @jls 8.3.1 Field Modifiers
 332      */
 333     public String toString() {
 334         int mod = getModifiers();
 335         return (((mod == 0) ? "" : (Modifier.toString(mod) + " "))
 336             + getType().getTypeName() + " "
 337             + getDeclaringClass().getTypeName() + "."
 338             + getName());
 339     }
 340 
 341     @Override
 342     String toShortString() {
 343         return "field " + getDeclaringClass().getTypeName() + "." + getName();
 344     }
 345 
 346     /**
 347      * Returns a string describing this {@code Field}, including
 348      * its generic type.  The format is the access modifiers for the
 349      * field, if any, followed by the generic field type, followed by
 350      * a space, followed by the fully-qualified name of the class
 351      * declaring the field, followed by a period, followed by the name
 352      * of the field.
 353      *
 354      * <p>The modifiers are placed in canonical order as specified by
 355      * "The Java Language Specification".  This is {@code public},
 356      * {@code protected} or {@code private} first, and then other
 357      * modifiers in the following order: {@code static}, {@code final},
 358      * {@code transient}, {@code volatile}.
 359      *
 360      * @return a string describing this {@code Field}, including
 361      * its generic type
 362      *
 363      * @since 1.5
 364      * @jls 8.3.1 Field Modifiers
 365      */
 366     public String toGenericString() {
 367         int mod = getModifiers();
 368         Type fieldType = getGenericType();
 369         return (((mod == 0) ? "" : (Modifier.toString(mod) + " "))
 370             + fieldType.getTypeName() + " "
 371             + getDeclaringClass().getTypeName() + "."
 372             + getName());
 373     }
 374 
 375     /**
 376      * Returns the value of the field represented by this {@code Field}, on
 377      * the specified object. The value is automatically wrapped in an
 378      * object if it has a primitive type.
 379      *
 380      * <p>The underlying field's value is obtained as follows:
 381      *
 382      * <p>If the underlying field is a static field, the {@code obj} argument
 383      * is ignored; it may be null.
 384      *
 385      * <p>Otherwise, the underlying field is an instance field.  If the
 386      * specified {@code obj} argument is null, the method throws a
 387      * {@code NullPointerException}. If the specified object is not an
 388      * instance of the class or interface declaring the underlying
 389      * field, the method throws an {@code IllegalArgumentException}.
 390      *
 391      * <p>If this {@code Field} object is enforcing Java language access control, and
 392      * the underlying field is inaccessible, the method throws an
 393      * {@code IllegalAccessException}.
 394      * If the underlying field is static, the class that declared the
 395      * field is initialized if it has not already been initialized.
 396      *
 397      * <p>Otherwise, the value is retrieved from the underlying instance
 398      * or static field.  If the field has a primitive type, the value
 399      * is wrapped in an object before being returned, otherwise it is
 400      * returned as is.
 401      *
 402      * <p>If the field is hidden in the type of {@code obj},
 403      * the field's value is obtained according to the preceding rules.
 404      *
 405      * @param obj object from which the represented field's value is
 406      * to be extracted
 407      * @return the value of the represented field in object
 408      * {@code obj}; primitive values are wrapped in an appropriate
 409      * object before being returned
 410      *
 411      * @throws    IllegalAccessException    if this {@code Field} object
 412      *              is enforcing Java language access control and the underlying
 413      *              field is inaccessible.
 414      * @throws    IllegalArgumentException  if the specified object is not an
 415      *              instance of the class or interface declaring the underlying
 416      *              field (or a subclass or implementor thereof).
 417      * @throws    NullPointerException      if the specified object is null
 418      *              and the field is an instance field.
 419      * @throws    ExceptionInInitializerError if the initialization provoked
 420      *              by this method fails.
 421      */
 422     @CallerSensitive
 423     @ForceInline // to ensure Reflection.getCallerClass optimization
 424     public Object get(Object obj)
 425         throws IllegalArgumentException, IllegalAccessException
 426     {
 427         if (!override) {
 428             Class<?> caller = Reflection.getCallerClass();
 429             checkAccess(caller, obj);
 430             return getFieldAccessor().get(obj);
 431         } else {
 432             return getOverrideFieldAccessor().get(obj);
 433         }
 434     }
 435 
 436     /**
 437      * Gets the value of a static or instance {@code boolean} field.
 438      *
 439      * @param obj the object to extract the {@code boolean} value
 440      * from
 441      * @return the value of the {@code boolean} field
 442      *
 443      * @throws    IllegalAccessException    if this {@code Field} object
 444      *              is enforcing Java language access control and the underlying
 445      *              field is inaccessible.
 446      * @throws    IllegalArgumentException  if the specified object is not
 447      *              an instance of the class or interface declaring the
 448      *              underlying field (or a subclass or implementor
 449      *              thereof), or if the field value cannot be
 450      *              converted to the type {@code boolean} by a
 451      *              widening conversion.
 452      * @throws    NullPointerException      if the specified object is null
 453      *              and the field is an instance field.
 454      * @throws    ExceptionInInitializerError if the initialization provoked
 455      *              by this method fails.
 456      * @see       Field#get
 457      */
 458     @CallerSensitive
 459     @ForceInline // to ensure Reflection.getCallerClass optimization
 460     public boolean getBoolean(Object obj)
 461         throws IllegalArgumentException, IllegalAccessException
 462     {
 463         if (!override) {
 464             Class<?> caller = Reflection.getCallerClass();
 465             checkAccess(caller, obj);
 466             return getFieldAccessor().getBoolean(obj);
 467         } else {
 468             return getOverrideFieldAccessor().getBoolean(obj);
 469         }
 470     }
 471 
 472     /**
 473      * Gets the value of a static or instance {@code byte} field.
 474      *
 475      * @param obj the object to extract the {@code byte} value
 476      * from
 477      * @return the value of the {@code byte} field
 478      *
 479      * @throws    IllegalAccessException    if this {@code Field} object
 480      *              is enforcing Java language access control and the underlying
 481      *              field is inaccessible.
 482      * @throws    IllegalArgumentException  if the specified object is not
 483      *              an instance of the class or interface declaring the
 484      *              underlying field (or a subclass or implementor
 485      *              thereof), or if the field value cannot be
 486      *              converted to the type {@code byte} by a
 487      *              widening conversion.
 488      * @throws    NullPointerException      if the specified object is null
 489      *              and the field is an instance field.
 490      * @throws    ExceptionInInitializerError if the initialization provoked
 491      *              by this method fails.
 492      * @see       Field#get
 493      */
 494     @CallerSensitive
 495     @ForceInline // to ensure Reflection.getCallerClass optimization
 496     public byte getByte(Object obj)
 497         throws IllegalArgumentException, IllegalAccessException
 498     {
 499         if (!override) {
 500             Class<?> caller = Reflection.getCallerClass();
 501             checkAccess(caller, obj);
 502             return getFieldAccessor().getByte(obj);
 503         } else {
 504             return getOverrideFieldAccessor().getByte(obj);
 505         }
 506     }
 507 
 508     /**
 509      * Gets the value of a static or instance field of type
 510      * {@code char} or of another primitive type convertible to
 511      * type {@code char} via a widening conversion.
 512      *
 513      * @param obj the object to extract the {@code char} value
 514      * from
 515      * @return the value of the field converted to type {@code char}
 516      *
 517      * @throws    IllegalAccessException    if this {@code Field} object
 518      *              is enforcing Java language access control and the underlying
 519      *              field is inaccessible.
 520      * @throws    IllegalArgumentException  if the specified object is not
 521      *              an instance of the class or interface declaring the
 522      *              underlying field (or a subclass or implementor
 523      *              thereof), or if the field value cannot be
 524      *              converted to the type {@code char} by a
 525      *              widening conversion.
 526      * @throws    NullPointerException      if the specified object is null
 527      *              and the field is an instance field.
 528      * @throws    ExceptionInInitializerError if the initialization provoked
 529      *              by this method fails.
 530      * @see Field#get
 531      */
 532     @CallerSensitive
 533     @ForceInline // to ensure Reflection.getCallerClass optimization
 534     public char getChar(Object obj)
 535         throws IllegalArgumentException, IllegalAccessException
 536     {
 537         if (!override) {
 538             Class<?> caller = Reflection.getCallerClass();
 539             checkAccess(caller, obj);
 540             return getFieldAccessor().getChar(obj);
 541         } else {
 542             return getOverrideFieldAccessor().getChar(obj);
 543         }
 544     }
 545 
 546     /**
 547      * Gets the value of a static or instance field of type
 548      * {@code short} or of another primitive type convertible to
 549      * type {@code short} via a widening conversion.
 550      *
 551      * @param obj the object to extract the {@code short} value
 552      * from
 553      * @return the value of the field converted to type {@code short}
 554      *
 555      * @throws    IllegalAccessException    if this {@code Field} object
 556      *              is enforcing Java language access control and the underlying
 557      *              field is inaccessible.
 558      * @throws    IllegalArgumentException  if the specified object is not
 559      *              an instance of the class or interface declaring the
 560      *              underlying field (or a subclass or implementor
 561      *              thereof), or if the field value cannot be
 562      *              converted to the type {@code short} by a
 563      *              widening conversion.
 564      * @throws    NullPointerException      if the specified object is null
 565      *              and the field is an instance field.
 566      * @throws    ExceptionInInitializerError if the initialization provoked
 567      *              by this method fails.
 568      * @see       Field#get
 569      */
 570     @CallerSensitive
 571     @ForceInline // to ensure Reflection.getCallerClass optimization
 572     public short getShort(Object obj)
 573         throws IllegalArgumentException, IllegalAccessException
 574     {
 575         if (!override) {
 576             Class<?> caller = Reflection.getCallerClass();
 577             checkAccess(caller, obj);
 578             return getFieldAccessor().getShort(obj);
 579         } else {
 580             return getOverrideFieldAccessor().getShort(obj);
 581         }
 582     }
 583 
 584     /**
 585      * Gets the value of a static or instance field of type
 586      * {@code int} or of another primitive type convertible to
 587      * type {@code int} via a widening conversion.
 588      *
 589      * @param obj the object to extract the {@code int} value
 590      * from
 591      * @return the value of the field converted to type {@code int}
 592      *
 593      * @throws    IllegalAccessException    if this {@code Field} object
 594      *              is enforcing Java language access control and the underlying
 595      *              field is inaccessible.
 596      * @throws    IllegalArgumentException  if the specified object is not
 597      *              an instance of the class or interface declaring the
 598      *              underlying field (or a subclass or implementor
 599      *              thereof), or if the field value cannot be
 600      *              converted to the type {@code int} by a
 601      *              widening conversion.
 602      * @throws    NullPointerException      if the specified object is null
 603      *              and the field is an instance field.
 604      * @throws    ExceptionInInitializerError if the initialization provoked
 605      *              by this method fails.
 606      * @see       Field#get
 607      */
 608     @CallerSensitive
 609     @ForceInline // to ensure Reflection.getCallerClass optimization
 610     public int getInt(Object obj)
 611         throws IllegalArgumentException, IllegalAccessException
 612     {
 613         if (!override) {
 614             Class<?> caller = Reflection.getCallerClass();
 615             checkAccess(caller, obj);
 616             return getFieldAccessor().getInt(obj);
 617         } else {
 618             return getOverrideFieldAccessor().getInt(obj);
 619         }
 620     }
 621 
 622     /**
 623      * Gets the value of a static or instance field of type
 624      * {@code long} or of another primitive type convertible to
 625      * type {@code long} via a widening conversion.
 626      *
 627      * @param obj the object to extract the {@code long} value
 628      * from
 629      * @return the value of the field converted to type {@code long}
 630      *
 631      * @throws    IllegalAccessException    if this {@code Field} object
 632      *              is enforcing Java language access control and the underlying
 633      *              field is inaccessible.
 634      * @throws    IllegalArgumentException  if the specified object is not
 635      *              an instance of the class or interface declaring the
 636      *              underlying field (or a subclass or implementor
 637      *              thereof), or if the field value cannot be
 638      *              converted to the type {@code long} by a
 639      *              widening conversion.
 640      * @throws    NullPointerException      if the specified object is null
 641      *              and the field is an instance field.
 642      * @throws    ExceptionInInitializerError if the initialization provoked
 643      *              by this method fails.
 644      * @see       Field#get
 645      */
 646     @CallerSensitive
 647     @ForceInline // to ensure Reflection.getCallerClass optimization
 648     public long getLong(Object obj)
 649         throws IllegalArgumentException, IllegalAccessException
 650     {
 651         if (!override) {
 652             Class<?> caller = Reflection.getCallerClass();
 653             checkAccess(caller, obj);
 654             return getFieldAccessor().getLong(obj);
 655         } else {
 656             return getOverrideFieldAccessor().getLong(obj);
 657         }
 658     }
 659 
 660     /**
 661      * Gets the value of a static or instance field of type
 662      * {@code float} or of another primitive type convertible to
 663      * type {@code float} via a widening conversion.
 664      *
 665      * @param obj the object to extract the {@code float} value
 666      * from
 667      * @return the value of the field converted to type {@code float}
 668      *
 669      * @throws    IllegalAccessException    if this {@code Field} object
 670      *              is enforcing Java language access control and the underlying
 671      *              field is inaccessible.
 672      * @throws    IllegalArgumentException  if the specified object is not
 673      *              an instance of the class or interface declaring the
 674      *              underlying field (or a subclass or implementor
 675      *              thereof), or if the field value cannot be
 676      *              converted to the type {@code float} by a
 677      *              widening conversion.
 678      * @throws    NullPointerException      if the specified object is null
 679      *              and the field is an instance field.
 680      * @throws    ExceptionInInitializerError if the initialization provoked
 681      *              by this method fails.
 682      * @see Field#get
 683      */
 684     @CallerSensitive
 685     @ForceInline // to ensure Reflection.getCallerClass optimization
 686     public float getFloat(Object obj)
 687         throws IllegalArgumentException, IllegalAccessException
 688     {
 689         if (!override) {
 690             Class<?> caller = Reflection.getCallerClass();
 691             checkAccess(caller, obj);
 692             return getFieldAccessor().getFloat(obj);
 693         } else {
 694             return getOverrideFieldAccessor().getFloat(obj);
 695         }
 696     }
 697 
 698     /**
 699      * Gets the value of a static or instance field of type
 700      * {@code double} or of another primitive type convertible to
 701      * type {@code double} via a widening conversion.
 702      *
 703      * @param obj the object to extract the {@code double} value
 704      * from
 705      * @return the value of the field converted to type {@code double}
 706      *
 707      * @throws    IllegalAccessException    if this {@code Field} object
 708      *              is enforcing Java language access control and the underlying
 709      *              field is inaccessible.
 710      * @throws    IllegalArgumentException  if the specified object is not
 711      *              an instance of the class or interface declaring the
 712      *              underlying field (or a subclass or implementor
 713      *              thereof), or if the field value cannot be
 714      *              converted to the type {@code double} by a
 715      *              widening conversion.
 716      * @throws    NullPointerException      if the specified object is null
 717      *              and the field is an instance field.
 718      * @throws    ExceptionInInitializerError if the initialization provoked
 719      *              by this method fails.
 720      * @see       Field#get
 721      */
 722     @CallerSensitive
 723     @ForceInline // to ensure Reflection.getCallerClass optimization
 724     public double getDouble(Object obj)
 725         throws IllegalArgumentException, IllegalAccessException
 726     {
 727         if (!override) {
 728             Class<?> caller = Reflection.getCallerClass();
 729             checkAccess(caller, obj);
 730             return getFieldAccessor().getDouble(obj);
 731         } else {
 732             return getOverrideFieldAccessor().getDouble(obj);
 733         }
 734     }
 735 
 736     /**
 737      * Sets the field represented by this {@code Field} object on the
 738      * specified object argument to the specified new value. The new
 739      * value is automatically unwrapped if the underlying field has a
 740      * primitive type.
 741      *
 742      * <p>The operation proceeds as follows:
 743      *
 744      * <p>If the underlying field is static, the {@code obj} argument is
 745      * ignored; it may be null.
 746      *
 747      * <p>Otherwise the underlying field is an instance field.  If the
 748      * specified object argument is null, the method throws a
 749      * {@code NullPointerException}.  If the specified object argument is not
 750      * an instance of the class or interface declaring the underlying
 751      * field, the method throws an {@code IllegalArgumentException}.
 752      *
 753      * <p>If this {@code Field} object is enforcing Java language access control, and
 754      * the underlying field is inaccessible, the method throws an
 755      * {@code IllegalAccessException}.
 756      *
 757      * <p>If the underlying field is final, this {@code Field} object has
 758      * <em>write</em> access if and only if the following conditions are met:
 759      * <ul>
 760      * <li>{@link #setAccessible(boolean) setAccessible(true)} has succeeded for
 761      *     this {@code Field} object;</li>
 762      * <li>the field is non-static; and</li>
 763      * <li>the field's declaring class is not a {@linkplain Class#isHidden()
 764      *     hidden class}; and</li>
 765      * <li>the field's declaring class is not a {@linkplain Class#isRecord()
 766      *     record class}.</li>
 767      * </ul>
 768      * If any of the above checks is not met, this method throws an
 769      * {@code IllegalAccessException}.
 770      *
 771      * <p> Setting a final field in this way
 772      * is meaningful only during deserialization or reconstruction of
 773      * instances of classes with blank final fields, before they are
 774      * made available for access by other parts of a program. Use in
 775      * any other context may have unpredictable effects, including cases
 776      * in which other parts of a program continue to use the original
 777      * value of this field.
 778      *
 779      * <p>If the underlying field is of a primitive type, an unwrapping
 780      * conversion is attempted to convert the new value to a value of
 781      * a primitive type.  If this attempt fails, the method throws an
 782      * {@code IllegalArgumentException}.
 783      *
 784      * <p>If, after possible unwrapping, the new value cannot be
 785      * converted to the type of the underlying field by an identity or
 786      * widening conversion, the method throws an
 787      * {@code IllegalArgumentException}.
 788      *
 789      * <p>If the underlying field is static, the class that declared the
 790      * field is initialized if it has not already been initialized.
 791      *
 792      * <p>The field is set to the possibly unwrapped and widened new value.
 793      *
 794      * <p>If the field is hidden in the type of {@code obj},
 795      * the field's value is set according to the preceding rules.
 796      *
 797      * @param obj the object whose field should be modified
 798      * @param value the new value for the field of {@code obj}
 799      * being modified
 800      *
 801      * @throws    IllegalAccessException    if this {@code Field} object
 802      *              is enforcing Java language access control and the underlying
 803      *              field is inaccessible or final;
 804      *              or if this {@code Field} object has no write access.
 805      * @throws    IllegalArgumentException  if the specified object is not an
 806      *              instance of the class or interface declaring the underlying
 807      *              field (or a subclass or implementor thereof),
 808      *              or if an unwrapping conversion fails.
 809      * @throws    NullPointerException      if the specified object is null
 810      *              and the field is an instance field.
 811      * @throws    ExceptionInInitializerError if the initialization provoked
 812      *              by this method fails.
 813      */
 814     @CallerSensitive
 815     @ForceInline // to ensure Reflection.getCallerClass optimization
 816     public void set(Object obj, Object value)
 817         throws IllegalArgumentException, IllegalAccessException
 818     {
 819         if (!override) {
 820             Class<?> caller = Reflection.getCallerClass();
 821             checkAccess(caller, obj);
 822             getFieldAccessor().set(obj, value);
 823         } else {
 824             getOverrideFieldAccessor().set(obj, value);
 825         }
 826     }
 827 
 828     /**
 829      * Sets the value of a field as a {@code boolean} on the specified object.
 830      * This method is equivalent to
 831      * {@code set(obj, zObj)},
 832      * where {@code zObj} is a {@code Boolean} object and
 833      * {@code zObj.booleanValue() == z}.
 834      *
 835      * @param obj the object whose field should be modified
 836      * @param z   the new value for the field of {@code obj}
 837      * being modified
 838      *
 839      * @throws    IllegalAccessException    if this {@code Field} object
 840      *              is enforcing Java language access control and the underlying
 841      *              field is either inaccessible or final;
 842      *              or if this {@code Field} object has no write access.
 843      * @throws    IllegalArgumentException  if the specified object is not an
 844      *              instance of the class or interface declaring the underlying
 845      *              field (or a subclass or implementor thereof),
 846      *              or if an unwrapping conversion fails.
 847      * @throws    NullPointerException      if the specified object is null
 848      *              and the field is an instance field.
 849      * @throws    ExceptionInInitializerError if the initialization provoked
 850      *              by this method fails.
 851      * @see       Field#set
 852      */
 853     @CallerSensitive
 854     @ForceInline // to ensure Reflection.getCallerClass optimization
 855     public void setBoolean(Object obj, boolean z)
 856         throws IllegalArgumentException, IllegalAccessException
 857     {
 858         if (!override) {
 859             Class<?> caller = Reflection.getCallerClass();
 860             checkAccess(caller, obj);
 861             getFieldAccessor().setBoolean(obj, z);
 862         } else {
 863             getOverrideFieldAccessor().setBoolean(obj, z);
 864         }
 865     }
 866 
 867     /**
 868      * Sets the value of a field as a {@code byte} on the specified object.
 869      * This method is equivalent to
 870      * {@code set(obj, bObj)},
 871      * where {@code bObj} is a {@code Byte} object and
 872      * {@code bObj.byteValue() == b}.
 873      *
 874      * @param obj the object whose field should be modified
 875      * @param b   the new value for the field of {@code obj}
 876      * being modified
 877      *
 878      * @throws    IllegalAccessException    if this {@code Field} object
 879      *              is enforcing Java language access control and the underlying
 880      *              field is either inaccessible or final;
 881      *              or if this {@code Field} object has no write access.
 882      * @throws    IllegalArgumentException  if the specified object is not an
 883      *              instance of the class or interface declaring the underlying
 884      *              field (or a subclass or implementor thereof),
 885      *              or if an unwrapping conversion fails.
 886      * @throws    NullPointerException      if the specified object is null
 887      *              and the field is an instance field.
 888      * @throws    ExceptionInInitializerError if the initialization provoked
 889      *              by this method fails.
 890      * @see       Field#set
 891      */
 892     @CallerSensitive
 893     @ForceInline // to ensure Reflection.getCallerClass optimization
 894     public void setByte(Object obj, byte b)
 895         throws IllegalArgumentException, IllegalAccessException
 896     {
 897         if (!override) {
 898             Class<?> caller = Reflection.getCallerClass();
 899             checkAccess(caller, obj);
 900             getFieldAccessor().setByte(obj, b);
 901         } else {
 902             getOverrideFieldAccessor().setByte(obj, b);
 903         }
 904     }
 905 
 906     /**
 907      * Sets the value of a field as a {@code char} on the specified object.
 908      * This method is equivalent to
 909      * {@code set(obj, cObj)},
 910      * where {@code cObj} is a {@code Character} object and
 911      * {@code cObj.charValue() == c}.
 912      *
 913      * @param obj the object whose field should be modified
 914      * @param c   the new value for the field of {@code obj}
 915      * being modified
 916      *
 917      * @throws    IllegalAccessException    if this {@code Field} object
 918      *              is enforcing Java language access control and the underlying
 919      *              field is either inaccessible or final;
 920      *              or if this {@code Field} object has no write access.
 921      * @throws    IllegalArgumentException  if the specified object is not an
 922      *              instance of the class or interface declaring the underlying
 923      *              field (or a subclass or implementor thereof),
 924      *              or if an unwrapping conversion fails.
 925      * @throws    NullPointerException      if the specified object is null
 926      *              and the field is an instance field.
 927      * @throws    ExceptionInInitializerError if the initialization provoked
 928      *              by this method fails.
 929      * @see       Field#set
 930      */
 931     @CallerSensitive
 932     @ForceInline // to ensure Reflection.getCallerClass optimization
 933     public void setChar(Object obj, char c)
 934         throws IllegalArgumentException, IllegalAccessException
 935     {
 936         if (!override) {
 937             Class<?> caller = Reflection.getCallerClass();
 938             checkAccess(caller, obj);
 939             getFieldAccessor().setChar(obj, c);
 940         } else {
 941             getOverrideFieldAccessor().setChar(obj, c);
 942         }
 943     }
 944 
 945     /**
 946      * Sets the value of a field as a {@code short} on the specified object.
 947      * This method is equivalent to
 948      * {@code set(obj, sObj)},
 949      * where {@code sObj} is a {@code Short} object and
 950      * {@code sObj.shortValue() == s}.
 951      *
 952      * @param obj the object whose field should be modified
 953      * @param s   the new value for the field of {@code obj}
 954      * being modified
 955      *
 956      * @throws    IllegalAccessException    if this {@code Field} object
 957      *              is enforcing Java language access control and the underlying
 958      *              field is either inaccessible or final;
 959      *              or if this {@code Field} object has no write access.
 960      * @throws    IllegalArgumentException  if the specified object is not an
 961      *              instance of the class or interface declaring the underlying
 962      *              field (or a subclass or implementor thereof),
 963      *              or if an unwrapping conversion fails.
 964      * @throws    NullPointerException      if the specified object is null
 965      *              and the field is an instance field.
 966      * @throws    ExceptionInInitializerError if the initialization provoked
 967      *              by this method fails.
 968      * @see       Field#set
 969      */
 970     @CallerSensitive
 971     @ForceInline // to ensure Reflection.getCallerClass optimization
 972     public void setShort(Object obj, short s)
 973         throws IllegalArgumentException, IllegalAccessException
 974     {
 975         if (!override) {
 976             Class<?> caller = Reflection.getCallerClass();
 977             checkAccess(caller, obj);
 978             getFieldAccessor().setShort(obj, s);
 979         } else {
 980             getOverrideFieldAccessor().setShort(obj, s);
 981         }
 982     }
 983 
 984     /**
 985      * Sets the value of a field as an {@code int} on the specified object.
 986      * This method is equivalent to
 987      * {@code set(obj, iObj)},
 988      * where {@code iObj} is an {@code Integer} object and
 989      * {@code iObj.intValue() == i}.
 990      *
 991      * @param obj the object whose field should be modified
 992      * @param i   the new value for the field of {@code obj}
 993      * being modified
 994      *
 995      * @throws    IllegalAccessException    if this {@code Field} object
 996      *              is enforcing Java language access control and the underlying
 997      *              field is either inaccessible or final;
 998      *              or if this {@code Field} object has no write access.
 999      * @throws    IllegalArgumentException  if the specified object is not an
1000      *              instance of the class or interface declaring the underlying
1001      *              field (or a subclass or implementor thereof),
1002      *              or if an unwrapping conversion fails.
1003      * @throws    NullPointerException      if the specified object is null
1004      *              and the field is an instance field.
1005      * @throws    ExceptionInInitializerError if the initialization provoked
1006      *              by this method fails.
1007      * @see       Field#set
1008      */
1009     @CallerSensitive
1010     @ForceInline // to ensure Reflection.getCallerClass optimization
1011     public void setInt(Object obj, int i)
1012         throws IllegalArgumentException, IllegalAccessException
1013     {
1014         if (!override) {
1015             Class<?> caller = Reflection.getCallerClass();
1016             checkAccess(caller, obj);
1017             getFieldAccessor().setInt(obj, i);
1018         } else {
1019             getOverrideFieldAccessor().setInt(obj, i);
1020         }
1021     }
1022 
1023     /**
1024      * Sets the value of a field as a {@code long} on the specified object.
1025      * This method is equivalent to
1026      * {@code set(obj, lObj)},
1027      * where {@code lObj} is a {@code Long} object and
1028      * {@code lObj.longValue() == l}.
1029      *
1030      * @param obj the object whose field should be modified
1031      * @param l   the new value for the field of {@code obj}
1032      * being modified
1033      *
1034      * @throws    IllegalAccessException    if this {@code Field} object
1035      *              is enforcing Java language access control and the underlying
1036      *              field is either inaccessible or final;
1037      *              or if this {@code Field} object has no write access.
1038      * @throws    IllegalArgumentException  if the specified object is not an
1039      *              instance of the class or interface declaring the underlying
1040      *              field (or a subclass or implementor thereof),
1041      *              or if an unwrapping conversion fails.
1042      * @throws    NullPointerException      if the specified object is null
1043      *              and the field is an instance field.
1044      * @throws    ExceptionInInitializerError if the initialization provoked
1045      *              by this method fails.
1046      * @see       Field#set
1047      */
1048     @CallerSensitive
1049     @ForceInline // to ensure Reflection.getCallerClass optimization
1050     public void setLong(Object obj, long l)
1051         throws IllegalArgumentException, IllegalAccessException
1052     {
1053         if (!override) {
1054             Class<?> caller = Reflection.getCallerClass();
1055             checkAccess(caller, obj);
1056             getFieldAccessor().setLong(obj, l);
1057         } else {
1058             getOverrideFieldAccessor().setLong(obj, l);
1059         }
1060     }
1061 
1062     /**
1063      * Sets the value of a field as a {@code float} on the specified object.
1064      * This method is equivalent to
1065      * {@code set(obj, fObj)},
1066      * where {@code fObj} is a {@code Float} object and
1067      * {@code fObj.floatValue() == f}.
1068      *
1069      * @param obj the object whose field should be modified
1070      * @param f   the new value for the field of {@code obj}
1071      * being modified
1072      *
1073      * @throws    IllegalAccessException    if this {@code Field} object
1074      *              is enforcing Java language access control and the underlying
1075      *              field is either inaccessible or final;
1076      *              or if this {@code Field} object has no write access.
1077      * @throws    IllegalArgumentException  if the specified object is not an
1078      *              instance of the class or interface declaring the underlying
1079      *              field (or a subclass or implementor thereof),
1080      *              or if an unwrapping conversion fails.
1081      * @throws    NullPointerException      if the specified object is null
1082      *              and the field is an instance field.
1083      * @throws    ExceptionInInitializerError if the initialization provoked
1084      *              by this method fails.
1085      * @see       Field#set
1086      */
1087     @CallerSensitive
1088     @ForceInline // to ensure Reflection.getCallerClass optimization
1089     public void setFloat(Object obj, float f)
1090         throws IllegalArgumentException, IllegalAccessException
1091     {
1092         if (!override) {
1093             Class<?> caller = Reflection.getCallerClass();
1094             checkAccess(caller, obj);
1095             getFieldAccessor().setFloat(obj, f);
1096         } else {
1097             getOverrideFieldAccessor().setFloat(obj, f);
1098         }
1099     }
1100 
1101     /**
1102      * Sets the value of a field as a {@code double} on the specified object.
1103      * This method is equivalent to
1104      * {@code set(obj, dObj)},
1105      * where {@code dObj} is a {@code Double} object and
1106      * {@code dObj.doubleValue() == d}.
1107      *
1108      * @param obj the object whose field should be modified
1109      * @param d   the new value for the field of {@code obj}
1110      * being modified
1111      *
1112      * @throws    IllegalAccessException    if this {@code Field} object
1113      *              is enforcing Java language access control and the underlying
1114      *              field is either inaccessible or final;
1115      *              or if this {@code Field} object has no write access.
1116      * @throws    IllegalArgumentException  if the specified object is not an
1117      *              instance of the class or interface declaring the underlying
1118      *              field (or a subclass or implementor thereof),
1119      *              or if an unwrapping conversion fails.
1120      * @throws    NullPointerException      if the specified object is null
1121      *              and the field is an instance field.
1122      * @throws    ExceptionInInitializerError if the initialization provoked
1123      *              by this method fails.
1124      * @see       Field#set
1125      */
1126     @CallerSensitive
1127     @ForceInline // to ensure Reflection.getCallerClass optimization
1128     public void setDouble(Object obj, double d)
1129         throws IllegalArgumentException, IllegalAccessException
1130     {
1131         if (!override) {
1132             Class<?> caller = Reflection.getCallerClass();
1133             checkAccess(caller, obj);
1134             getFieldAccessor().setDouble(obj, d);
1135         } else {
1136             getOverrideFieldAccessor().setDouble(obj, d);
1137         }
1138     }
1139 
1140     // check access to field
1141     private void checkAccess(Class<?> caller, Object obj)
1142         throws IllegalAccessException
1143     {
1144         checkAccess(caller, clazz,
1145                     Modifier.isStatic(modifiers) ? null : obj.getClass(),
1146                     modifiers);
1147     }
1148 
1149     // security check is done before calling this method
1150     private FieldAccessor getFieldAccessor() {
1151         FieldAccessor a = fieldAccessor;
1152         return (a != null) ? a : acquireFieldAccessor();
1153     }
1154 
1155     private FieldAccessor getOverrideFieldAccessor() {
1156         FieldAccessor a = overrideFieldAccessor;
1157         return (a != null) ? a : acquireOverrideFieldAccessor();
1158     }
1159 
1160     // NOTE that there is no synchronization used here. It is correct
1161     // (though not efficient) to generate more than one FieldAccessor
1162     // for a given Field. However, avoiding synchronization will
1163     // probably make the implementation more scalable.
1164     private FieldAccessor acquireFieldAccessor() {
1165         // First check to see if one has been created yet, and take it
1166         // if so
1167         Field root = this.root;
1168         FieldAccessor tmp = root == null ? null : root.fieldAccessor;
1169         if (tmp != null) {
1170             fieldAccessor = tmp;
1171         } else {
1172             // Otherwise fabricate one and propagate it up to the root
1173             tmp = reflectionFactory.newFieldAccessor(this, false);
1174             setFieldAccessor(tmp);
1175         }
1176         return tmp;
1177     }
1178 
1179     private FieldAccessor acquireOverrideFieldAccessor() {
1180         // First check to see if one has been created yet, and take it
1181         // if so
1182         Field root = this.root;
1183         FieldAccessor tmp = root == null ? null : root.overrideFieldAccessor;
1184         if (tmp != null) {
1185             overrideFieldAccessor = tmp;
1186         } else {
1187             // Otherwise fabricate one and propagate it up to the root
1188             tmp = reflectionFactory.newFieldAccessor(this, true);
1189             setOverrideFieldAccessor(tmp);
1190         }
1191         return tmp;
1192     }
1193 
1194     // Sets the fieldAccessor for this Field object and
1195     // (recursively) its root
1196     private void setFieldAccessor(FieldAccessor accessor) {
1197         fieldAccessor = accessor;
1198         // Propagate up
1199         Field root = this.root;
1200         if (root != null) {
1201             root.setFieldAccessor(accessor);
1202         }
1203     }
1204 
1205     // Sets the overrideFieldAccessor for this Field object and
1206     // (recursively) its root
1207     private void setOverrideFieldAccessor(FieldAccessor accessor) {
1208         overrideFieldAccessor = accessor;
1209         // Propagate up
1210         Field root = this.root;
1211         if (root != null) {
1212             root.setOverrideFieldAccessor(accessor);
1213         }
1214     }
1215 
1216     @Override
1217     /* package-private */ Field getRoot() {
1218         return root;
1219     }
1220 
1221     /* package-private */ boolean isTrustedFinal() {
1222         return trustedFinal;
1223     }
1224 
1225     /**
1226      * {@inheritDoc}
1227      *
1228      * @throws NullPointerException {@inheritDoc}
1229      * @since 1.5
1230      */
1231     @Override
1232     public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
1233         Objects.requireNonNull(annotationClass);
1234         return annotationClass.cast(declaredAnnotations().get(annotationClass));
1235     }
1236 
1237     /**
1238      * {@inheritDoc}
1239      *
1240      * @throws NullPointerException {@inheritDoc}
1241      * @since 1.8
1242      */
1243     @Override
1244     public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) {
1245         Objects.requireNonNull(annotationClass);
1246 
1247         return AnnotationSupport.getDirectlyAndIndirectlyPresent(declaredAnnotations(), annotationClass);
1248     }
1249 
1250     /**
1251      * {@inheritDoc}
1252      */
1253     @Override
1254     public Annotation[] getDeclaredAnnotations()  {
1255         return AnnotationParser.toArray(declaredAnnotations());
1256     }
1257 
1258     private transient volatile Map<Class<? extends Annotation>, Annotation> declaredAnnotations;
1259 
1260     private Map<Class<? extends Annotation>, Annotation> declaredAnnotations() {
1261         Map<Class<? extends Annotation>, Annotation> declAnnos;
1262         if ((declAnnos = declaredAnnotations) == null) {
1263             synchronized (this) {
1264                 if ((declAnnos = declaredAnnotations) == null) {
1265                     Field root = this.root;
1266                     if (root != null) {
1267                         declAnnos = root.declaredAnnotations();
1268                     } else {
1269                         declAnnos = AnnotationParser.parseAnnotations(
1270                                 annotations,
1271                                 SharedSecrets.getJavaLangAccess()
1272                                         .getConstantPool(getDeclaringClass()),
1273                                 getDeclaringClass());
1274                     }
1275                     declaredAnnotations = declAnnos;
1276                 }
1277             }
1278         }
1279         return declAnnos;
1280     }
1281 
1282     private native byte[] getTypeAnnotationBytes0();
1283 
1284     /**
1285      * Returns an AnnotatedType object that represents the use of a type to specify
1286      * the declared type of the field represented by this Field.
1287      * @return an object representing the declared type of the field
1288      * represented by this Field
1289      *
1290      * @since 1.8
1291      */
1292     public AnnotatedType getAnnotatedType() {
1293         return TypeAnnotationParser.buildAnnotatedType(getTypeAnnotationBytes0(),
1294                                                        SharedSecrets.getJavaLangAccess().
1295                                                            getConstantPool(getDeclaringClass()),
1296                                                        this,
1297                                                        getDeclaringClass(),
1298                                                        getGenericType(),
1299                                                        TypeAnnotation.TypeAnnotationTarget.FIELD);
1300 }
1301 }