1115 1116 // Sets the FieldAccessor for this Field object and 1117 // (recursively) its root 1118 private void setFieldAccessor(FieldAccessor accessor, boolean overrideFinalCheck) { 1119 if (overrideFinalCheck) 1120 overrideFieldAccessor = accessor; 1121 else 1122 fieldAccessor = accessor; 1123 // Propagate up 1124 if (root != null) { 1125 root.setFieldAccessor(accessor, overrideFinalCheck); 1126 } 1127 } 1128 1129 @Override 1130 Field getRoot() { 1131 return root; 1132 } 1133 1134 /** 1135 * @throws NullPointerException {@inheritDoc} 1136 * @since 1.5 1137 */ 1138 public <T extends Annotation> T getAnnotation(Class<T> annotationClass) { 1139 Objects.requireNonNull(annotationClass); 1140 return annotationClass.cast(declaredAnnotations().get(annotationClass)); 1141 } 1142 1143 /** 1144 * {@inheritDoc} 1145 * @throws NullPointerException {@inheritDoc} 1146 * @since 1.8 1147 */ 1148 @Override 1149 public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) { 1150 Objects.requireNonNull(annotationClass); 1151 1152 return AnnotationSupport.getDirectlyAndIndirectlyPresent(declaredAnnotations(), annotationClass); 1153 } 1154 1155 /** 1156 * {@inheritDoc} 1157 */ 1158 public Annotation[] getDeclaredAnnotations() { 1159 return AnnotationParser.toArray(declaredAnnotations()); 1160 } 1161 1162 private transient volatile Map<Class<? extends Annotation>, Annotation> declaredAnnotations; 1163 1164 private Map<Class<? extends Annotation>, Annotation> declaredAnnotations() { 1165 Map<Class<? extends Annotation>, Annotation> declAnnos; 1166 if ((declAnnos = declaredAnnotations) == null) { 1167 synchronized (this) { 1168 if ((declAnnos = declaredAnnotations) == null) { 1169 Field root = this.root; 1170 if (root != null) { 1171 declAnnos = root.declaredAnnotations(); 1172 } else { 1173 declAnnos = AnnotationParser.parseAnnotations( 1174 annotations, 1175 SharedSecrets.getJavaLangAccess() 1176 .getConstantPool(getDeclaringClass()), 1177 getDeclaringClass()); | 1115 1116 // Sets the FieldAccessor for this Field object and 1117 // (recursively) its root 1118 private void setFieldAccessor(FieldAccessor accessor, boolean overrideFinalCheck) { 1119 if (overrideFinalCheck) 1120 overrideFieldAccessor = accessor; 1121 else 1122 fieldAccessor = accessor; 1123 // Propagate up 1124 if (root != null) { 1125 root.setFieldAccessor(accessor, overrideFinalCheck); 1126 } 1127 } 1128 1129 @Override 1130 Field getRoot() { 1131 return root; 1132 } 1133 1134 /** 1135 * {@inheritDoc} 1136 * 1137 * @throws NullPointerException {@inheritDoc} 1138 * @since 1.5 1139 */ 1140 @Override 1141 public <T extends Annotation> T getAnnotation(Class<T> annotationClass) { 1142 Objects.requireNonNull(annotationClass); 1143 return annotationClass.cast(declaredAnnotations().get(annotationClass)); 1144 } 1145 1146 /** 1147 * {@inheritDoc} 1148 * 1149 * @throws NullPointerException {@inheritDoc} 1150 * @since 1.8 1151 */ 1152 @Override 1153 public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) { 1154 Objects.requireNonNull(annotationClass); 1155 1156 return AnnotationSupport.getDirectlyAndIndirectlyPresent(declaredAnnotations(), annotationClass); 1157 } 1158 1159 /** 1160 * {@inheritDoc} 1161 */ 1162 @Override 1163 public Annotation[] getDeclaredAnnotations() { 1164 return AnnotationParser.toArray(declaredAnnotations()); 1165 } 1166 1167 private transient volatile Map<Class<? extends Annotation>, Annotation> declaredAnnotations; 1168 1169 private Map<Class<? extends Annotation>, Annotation> declaredAnnotations() { 1170 Map<Class<? extends Annotation>, Annotation> declAnnos; 1171 if ((declAnnos = declaredAnnotations) == null) { 1172 synchronized (this) { 1173 if ((declAnnos = declaredAnnotations) == null) { 1174 Field root = this.root; 1175 if (root != null) { 1176 declAnnos = root.declaredAnnotations(); 1177 } else { 1178 declAnnos = AnnotationParser.parseAnnotations( 1179 annotations, 1180 SharedSecrets.getJavaLangAccess() 1181 .getConstantPool(getDeclaringClass()), 1182 getDeclaringClass()); |