< prev index next >

src/java.base/share/classes/java/lang/reflect/Field.java

Print this page


   1 /*
   2  * Copyright (c) 1996, 2019, 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


 226     public boolean isSynthetic() {
 227         return Modifier.isSynthetic(getModifiers());
 228     }
 229 
 230     /**
 231      * Returns a {@code Class} object that identifies the
 232      * declared type for the field represented by this
 233      * {@code Field} object.
 234      *
 235      * @return a {@code Class} object identifying the declared
 236      * type of the field represented by this object
 237      */
 238     public Class<?> getType() {
 239         return type;
 240     }
 241 
 242     /**
 243      * Returns a {@code Type} object that represents the declared type for
 244      * the field represented by this {@code Field} object.
 245      *
 246      * <p>If the declared type of the field is a parameterized type,
 247      * the {@code Type} object returned must accurately reflect the
 248      * actual type arguments used in the source code.
 249      *
 250      * <p>If the type of the underlying field is a type variable or a
 251      * parameterized type, it is created. Otherwise, it is resolved.
 252      *
 253      * @return a {@code Type} object that represents the declared type for
 254      *     the field represented by this {@code Field} object
 255      * @throws GenericSignatureFormatError if the generic field
 256      *     signature does not conform to the format specified in
 257      *     <cite>The Java&trade; Virtual Machine Specification</cite>
 258      * @throws TypeNotPresentException if the generic type
 259      *     signature of the underlying field refers to a non-existent
 260      *     type declaration
 261      * @throws MalformedParameterizedTypeException if the generic
 262      *     signature of the underlying field refers to a parameterized type
 263      *     that cannot be instantiated for any reason
 264      * @since 1.5
 265      */
 266     public Type getGenericType() {
 267         if (getGenericSignature() != null)
 268             return getGenericInfo().getGenericType();


   1 /*
   2  * Copyright (c) 1996, 2018, 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


 226     public boolean isSynthetic() {
 227         return Modifier.isSynthetic(getModifiers());
 228     }
 229 
 230     /**
 231      * Returns a {@code Class} object that identifies the
 232      * declared type for the field represented by this
 233      * {@code Field} object.
 234      *
 235      * @return a {@code Class} object identifying the declared
 236      * type of the field represented by this object
 237      */
 238     public Class<?> getType() {
 239         return type;
 240     }
 241 
 242     /**
 243      * Returns a {@code Type} object that represents the declared type for
 244      * the field represented by this {@code Field} object.
 245      *
 246      * <p>If the {@code Type} is a parameterized type, the
 247      * {@code Type} object returned must accurately reflect the
 248      * actual type parameters used in the source code.
 249      *
 250      * <p>If the type of the underlying field is a type variable or a
 251      * parameterized type, it is created. Otherwise, it is resolved.
 252      *
 253      * @return a {@code Type} object that represents the declared type for
 254      *     the field represented by this {@code Field} object
 255      * @throws GenericSignatureFormatError if the generic field
 256      *     signature does not conform to the format specified in
 257      *     <cite>The Java&trade; Virtual Machine Specification</cite>
 258      * @throws TypeNotPresentException if the generic type
 259      *     signature of the underlying field refers to a non-existent
 260      *     type declaration
 261      * @throws MalformedParameterizedTypeException if the generic
 262      *     signature of the underlying field refers to a parameterized type
 263      *     that cannot be instantiated for any reason
 264      * @since 1.5
 265      */
 266     public Type getGenericType() {
 267         if (getGenericSignature() != null)
 268             return getGenericInfo().getGenericType();


< prev index next >