/patches/openjdk/8011139-revise_checking_getenclosingclass.patch
https://bitbucket.org/Ringdingcoder/icedtea6 · Patch · 58 lines · 52 code · 6 blank · 0 comment · 0 complexity · 7f510765bc8a489ef904e66bf0686990 MD5 · raw file
- changeset: 4968:2d3faf217561
- user: jfranck
- date: Thu Apr 18 13:18:28 2013 +0200
- files: src/share/classes/java/lang/Class.java
- description:
- 8011139: (reflect) Revise checking in getEnclosingClass
- Reviewed-by: darcy, mchung, ahgross
- --- openjdk/jdk/src/share/classes/java/lang/Class.java
- +++ openjdk/jdk/src/share/classes/java/lang/Class.java
- @@ -1134,13 +1134,9 @@
- enclosingCandidate = enclosingClass;
- }
-
- - // be very careful not to change the stack depth of this
- - // checkMemberAccess call for security reasons
- - // see java.lang.SecurityManager.checkMemberAccess
- - if (enclosingCandidate != null) {
- - enclosingCandidate.checkMemberAccess(Member.DECLARED,
- - Reflection.getCallerClass(), true);
- - }
- + if (enclosingCandidate != null)
- + enclosingCandidate.checkPackageAccess(
- + ClassLoader.getClassLoader(Reflection.getCallerClass()), true);
- return enclosingCandidate;
- }
-
- @@ -2214,6 +2210,8 @@
- * Check if client is allowed to access members. If access is denied,
- * throw a SecurityException.
- *
- + * This method also enforces package access.
- + *
- * <p> Default policy: allow all clients access with normal Java access
- * control.
- */
- @@ -2234,7 +2232,19 @@
- // checkMemberAccess of subclasses of SecurityManager as specified.
- s.checkMemberAccess(this, which);
- }
- + this.checkPackageAccess(ccl, checkProxyInterfaces);
- + }
- + }
-
- + /*
- + * Checks if a client loaded in ClassLoader ccl is allowed to access this
- + * class under the current package access policy. If access is denied,
- + * throw a SecurityException.
- + */
- + private void checkPackageAccess(final ClassLoader ccl, boolean checkProxyInterfaces) {
- + final SecurityManager s = System.getSecurityManager();
- + if (s != null) {
- + final ClassLoader cl = getClassLoader0();
- if (ReflectUtil.needsPackageAccessCheck(ccl, cl)) {
- String name = this.getName();
- int i = name.lastIndexOf('.');