< prev index next >

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

Print this page




 168     public void setAccessible(boolean flag) {
 169         AccessibleObject.checkPermission();
 170 
 171         if (flag) {
 172             if (clazz.isValue()) {
 173                 throw new InaccessibleObjectException(
 174                     "Unable to make a value class field \"" + this + "\" accessible");
 175             }
 176 
 177             checkCanSetAccessible(Reflection.getCallerClass());
 178         }
 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




 168     public void setAccessible(boolean flag) {
 169         AccessibleObject.checkPermission();
 170 
 171         if (flag) {
 172             if (clazz.isValue()) {
 173                 throw new InaccessibleObjectException(
 174                     "Unable to make a value class field \"" + this + "\" accessible");
 175             }
 176 
 177             checkCanSetAccessible(Reflection.getCallerClass());
 178         }
 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
 189      * {@linkplain Class#asBoxType() the box type} of the class or interface
 190      * that declares the field represented by this {@code Field} object.
 191      */
 192     @Override
 193     public Class<?> getDeclaringClass() {
 194         return clazz;
 195     }
 196 
 197     /**
 198      * Returns the name of the field represented by this {@code Field} object.
 199      */
 200     public String getName() {
 201         return name;
 202     }
 203 
 204     /**
 205      * Returns the Java language modifiers for the field represented
 206      * by this {@code Field} object, as an integer. The {@code Modifier} class should
 207      * be used to decode the modifiers.
 208      *
 209      * @see Modifier


< prev index next >