< prev index next >

src/java.base/share/classes/java/lang/SecurityManager.java

Print this page
rev 52881 : 8214971: Replace use of string.equals("") with isEmpty()
Reviewed-by: jlaskey, prappo, lancea, dfuchs, redestad


1184      *
1185      * Locking is handled by synchronization to the
1186      * packageAccessLock/packageDefinitionLock objects.  They are only
1187      * used in this class.
1188      *
1189      * Note that cache invalidation as a result of the property change
1190      * happens without using these locks, so there may be a delay between
1191      * when a thread updates the property and when other threads updates
1192      * the cache.
1193      */
1194     private static boolean packageAccessValid = false;
1195     private static String[] packageAccess;
1196     private static final Object packageAccessLock = new Object();
1197 
1198     private static boolean packageDefinitionValid = false;
1199     private static String[] packageDefinition;
1200     private static final Object packageDefinitionLock = new Object();
1201 
1202     private static String[] getPackages(String p) {
1203         String packages[] = null;
1204         if (p != null && !p.equals("")) {
1205             java.util.StringTokenizer tok =
1206                 new java.util.StringTokenizer(p, ",");
1207             int n = tok.countTokens();
1208             if (n > 0) {
1209                 packages = new String[n];
1210                 int i = 0;
1211                 while (tok.hasMoreElements()) {
1212                     String s = tok.nextToken().trim();
1213                     packages[i++] = s;
1214                 }
1215             }
1216         }
1217 
1218         if (packages == null) {
1219             packages = new String[0];
1220         }
1221         return packages;
1222     }
1223 
1224     // The non-exported packages in modules defined to the boot or platform




1184      *
1185      * Locking is handled by synchronization to the
1186      * packageAccessLock/packageDefinitionLock objects.  They are only
1187      * used in this class.
1188      *
1189      * Note that cache invalidation as a result of the property change
1190      * happens without using these locks, so there may be a delay between
1191      * when a thread updates the property and when other threads updates
1192      * the cache.
1193      */
1194     private static boolean packageAccessValid = false;
1195     private static String[] packageAccess;
1196     private static final Object packageAccessLock = new Object();
1197 
1198     private static boolean packageDefinitionValid = false;
1199     private static String[] packageDefinition;
1200     private static final Object packageDefinitionLock = new Object();
1201 
1202     private static String[] getPackages(String p) {
1203         String packages[] = null;
1204         if (p != null && !p.isEmpty()) {
1205             java.util.StringTokenizer tok =
1206                 new java.util.StringTokenizer(p, ",");
1207             int n = tok.countTokens();
1208             if (n > 0) {
1209                 packages = new String[n];
1210                 int i = 0;
1211                 while (tok.hasMoreElements()) {
1212                     String s = tok.nextToken().trim();
1213                     packages[i++] = s;
1214                 }
1215             }
1216         }
1217 
1218         if (packages == null) {
1219             packages = new String[0];
1220         }
1221         return packages;
1222     }
1223 
1224     // The non-exported packages in modules defined to the boot or platform


< prev index next >