src/share/classes/java/lang/reflect/Field.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 34,44 ****
import java.lang.annotation.Annotation;
import java.util.Map;
import java.util.Objects;
import sun.reflect.annotation.AnnotationParser;
import sun.reflect.annotation.AnnotationSupport;
!
/**
* A {@code Field} provides information about, and dynamic access to, a
* single field of a class or an interface. The reflected field may
* be a class (static) field or an instance field.
--- 34,45 ----
import java.lang.annotation.Annotation;
import java.util.Map;
import java.util.Objects;
import sun.reflect.annotation.AnnotationParser;
import sun.reflect.annotation.AnnotationSupport;
! import sun.reflect.annotation.TypeAnnotation;
! import sun.reflect.annotation.TypeAnnotationParser;
/**
* A {@code Field} provides information about, and dynamic access to, a
* single field of a class or an interface. The reflected field may
* be a class (static) field or an instance field.
*** 1051,1056 ****
--- 1052,1073 ----
getConstantPool(getDeclaringClass()),
getDeclaringClass());
}
return declaredAnnotations;
}
+
+ /**
+ * Returns an AnnotatedType object that represents the use of a type to denote
+ * the declared type of the field represented by this Field.
+ *
+ * @since 1.8
+ */
+ public AnnotatedType getAnnotatedType() {
+ return TypeAnnotationParser.buildAnnotatedType0(typeAnnotations,
+ sun.misc.SharedSecrets.getJavaLangAccess().
+ getConstantPool(getDeclaringClass()),
+ this,
+ getDeclaringClass(),
+ getGenericType(),
+ TypeAnnotation.TypeAnnotationTarget.FIELD_TYPE);
+ }
}