< prev index next >

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

Print this page




 161 
 162     /**
 163      * {@inheritDoc}
 164      *
 165      * <p> A {@code SecurityException} is also thrown if this object is a
 166      * {@code Constructor} object for the class {@code Class} and {@code flag}
 167      * is true. </p>
 168      *
 169      * @param flag {@inheritDoc}
 170      *
 171      * @throws InaccessibleObjectException {@inheritDoc}
 172      * @throws SecurityException if the request is denied by the security manager
 173      *         or this is a constructor for {@code java.lang.Class}
 174      *
 175      * @spec JPMS
 176      */
 177     @Override
 178     @CallerSensitive
 179     public void setAccessible(boolean flag) {
 180         AccessibleObject.checkPermission();

 181         if (flag) {
 182             checkCanSetAccessible(Reflection.getCallerClass());
 183         }
 184         setAccessible0(flag);
 185     }
 186 
 187     @Override
 188     void checkCanSetAccessible(Class<?> caller) {
 189         checkCanSetAccessible(caller, clazz);
 190         if (clazz == Class.class) {
 191             // can we change this to InaccessibleObjectException?
 192             throw new SecurityException("Cannot make a java.lang.Class"
 193                                         + " constructor accessible");
 194         }
 195     }
 196 
 197     @Override
 198     boolean hasGenericInformation() {
 199         return (getSignature() != null);
 200     }




 161 
 162     /**
 163      * {@inheritDoc}
 164      *
 165      * <p> A {@code SecurityException} is also thrown if this object is a
 166      * {@code Constructor} object for the class {@code Class} and {@code flag}
 167      * is true. </p>
 168      *
 169      * @param flag {@inheritDoc}
 170      *
 171      * @throws InaccessibleObjectException {@inheritDoc}
 172      * @throws SecurityException if the request is denied by the security manager
 173      *         or this is a constructor for {@code java.lang.Class}
 174      *
 175      * @spec JPMS
 176      */
 177     @Override
 178     @CallerSensitive
 179     public void setAccessible(boolean flag) {
 180         AccessibleObject.checkPermission();
 181 
 182         if (flag) {
 183             checkCanSetAccessible(Reflection.getCallerClass());
 184         }
 185         setAccessible0(flag);
 186     }
 187 
 188     @Override
 189     void checkCanSetAccessible(Class<?> caller) {
 190         checkCanSetAccessible(caller, clazz);
 191         if (clazz == Class.class) {
 192             // can we change this to InaccessibleObjectException?
 193             throw new SecurityException("Cannot make a java.lang.Class"
 194                                         + " constructor accessible");
 195         }
 196     }
 197 
 198     @Override
 199     boolean hasGenericInformation() {
 200         return (getSignature() != null);
 201     }


< prev index next >