< prev index next >

src/java.base/share/classes/java/security/Security.java

Print this page

        

*** 23,37 **** * questions. */ package java.security; - import java.lang.reflect.*; import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.io.*; import java.net.URL; import sun.security.util.Debug; import sun.security.util.PropertyExpander; import sun.security.jca.*; --- 23,38 ---- * questions. */ package java.security; import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.io.*; import java.net.URL; + + import jdk.internal.misc.SharedSecrets; import sun.security.util.Debug; import sun.security.util.PropertyExpander; import sun.security.jca.*;
*** 798,853 **** * Implementation detail: If the property we just set in * setProperty() was either "package.access" or * "package.definition", we need to signal to the SecurityManager * class that the value has just changed, and that it should * invalidate it's local cache values. - * - * Rather than create a new API entry for this function, - * we use reflection to set a private variable. */ private static void invalidateSMCache(String key) { final boolean pa = key.equals("package.access"); final boolean pd = key.equals("package.definition"); if (pa || pd) { ! AccessController.doPrivileged(new PrivilegedAction<>() { ! public Void run() { ! try { ! /* Get the class via the bootstrap class loader. */ ! Class<?> cl = Class.forName( ! "java.lang.SecurityManager", false, null); ! Field f = null; ! boolean accessible = false; ! ! if (pa) { ! f = cl.getDeclaredField("packageAccessValid"); ! accessible = f.isAccessible(); ! f.setAccessible(true); ! } else { ! f = cl.getDeclaredField("packageDefinitionValid"); ! accessible = f.isAccessible(); ! f.setAccessible(true); ! } ! f.setBoolean(f, false); ! f.setAccessible(accessible); ! } ! catch (Exception e1) { ! /* If we couldn't get the class, it hasn't ! * been loaded yet. If there is no such ! * field, we shouldn't try to set it. There ! * shouldn't be a security execption, as we ! * are loaded by boot class loader, and we ! * are inside a doPrivileged() here. ! * ! * NOOP: don't do anything... ! */ } - return null; - } /* run */ - }); /* PrivilegedAction */ - } /* if */ } private static void check(String directive) { SecurityManager security = System.getSecurityManager(); if (security != null) { --- 799,817 ---- * Implementation detail: If the property we just set in * setProperty() was either "package.access" or * "package.definition", we need to signal to the SecurityManager * class that the value has just changed, and that it should * invalidate it's local cache values. */ private static void invalidateSMCache(String key) { final boolean pa = key.equals("package.access"); final boolean pd = key.equals("package.definition"); if (pa || pd) { ! SharedSecrets.getJavaLangAccess().invalidatePackageAccessCache(); } } private static void check(String directive) { SecurityManager security = System.getSecurityManager(); if (security != null) {
< prev index next >