< prev index next >

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

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 1997, 2019, 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) 1997, 2018, 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
*** 54,67 **** * exported} package and the user {@link Module#canRead reads} their module. By * default, Java language access control is enforced (with one variation) when * {@code Field}s, {@code Method}s, or {@code Constructor}s are used to get or * set fields, to invoke methods, or to create and initialize new instances of * classes, respectively. Every reflected object checks that the code using it ! * is in an appropriate class, package, or module. The check when invoked by ! * <a href="{@docRoot}/../specs/jni/index.html">JNI code</a> with no Java ! * class on the stack only succeeds if the member and the declaring class are ! * public, and the class is in a package that is exported to all modules. </p> * * <p> The one variation from Java language access control is that the checks * by reflected objects assume readability. That is, the module containing * the use of a reflected object is assumed to read the module in which * the underlying field, method, or constructor is declared. </p> --- 54,64 ---- * exported} package and the user {@link Module#canRead reads} their module. By * default, Java language access control is enforced (with one variation) when * {@code Field}s, {@code Method}s, or {@code Constructor}s are used to get or * set fields, to invoke methods, or to create and initialize new instances of * classes, respectively. Every reflected object checks that the code using it ! * is in an appropriate class, package, or module. </p> * * <p> The one variation from Java language access control is that the checks * by reflected objects assume readability. That is, the module containing * the use of a reflected object is assumed to read the module in which * the underlying field, method, or constructor is declared. </p>
*** 671,687 **** // Keep all this slow stuff out of line: private boolean slowVerifyAccess(Class<?> caller, Class<?> memberClass, Class<?> targetClass, int modifiers) { - - if (caller == null) { - // No caller frame when a native thread attaches to the VM - // only allow access to a public accessible member - return Reflection.verifyPublicMemberAccess(memberClass, modifiers); - } - if (!Reflection.verifyMemberAccess(caller, memberClass, targetClass, modifiers)) { // access denied return false; } --- 668,677 ----
< prev index next >