src/share/classes/java/util/PropertyPermission.java

Print this page
rev 4788 : Fix bunch of generics warnings

*** 440,450 **** /** * Key is property name; value is PropertyPermission. * Not serialized; see serialization section at end of class. */ ! private transient Map perms; /** * Boolean saying if "*" is in the collection. * * @see #serialPersistentFields --- 440,450 ---- /** * Key is property name; value is PropertyPermission. * Not serialized; see serialization section at end of class. */ ! private transient Map<String, PropertyPermission> perms; /** * Boolean saying if "*" is in the collection. * * @see #serialPersistentFields
*** 456,466 **** * Create an empty PropertyPermissions object. * */ public PropertyPermissionCollection() { ! perms = new HashMap(32); // Capacity for default policy all_allowed = false; } /** * Adds a permission to the PropertyPermissions. The key for the hash is --- 456,466 ---- * Create an empty PropertyPermissions object. * */ public PropertyPermissionCollection() { ! perms = new HashMap<>(32); // Capacity for default policy all_allowed = false; } /** * Adds a permission to the PropertyPermissions. The key for the hash is
*** 486,507 **** PropertyPermission pp = (PropertyPermission) permission; String propName = pp.getName(); synchronized (this) { ! PropertyPermission existing = (PropertyPermission) perms.get(propName); if (existing != null) { int oldMask = existing.getMask(); int newMask = pp.getMask(); if (oldMask != newMask) { int effective = oldMask | newMask; String actions = PropertyPermission.getActions(effective); perms.put(propName, new PropertyPermission(propName, actions)); } } else { ! perms.put(propName, permission); } } if (!all_allowed) { if (propName.equals("*")) --- 486,507 ---- PropertyPermission pp = (PropertyPermission) permission; String propName = pp.getName(); synchronized (this) { ! PropertyPermission existing = perms.get(propName); if (existing != null) { int oldMask = existing.getMask(); int newMask = pp.getMask(); if (oldMask != newMask) { int effective = oldMask | newMask; String actions = PropertyPermission.getActions(effective); perms.put(propName, new PropertyPermission(propName, actions)); } } else { ! perms.put(propName, pp); } } if (!all_allowed) { if (propName.equals("*"))
*** 531,541 **** int effective = 0; // short circuit if the "*" Permission was added if (all_allowed) { synchronized (this) { ! x = (PropertyPermission) perms.get("*"); } if (x != null) { effective |= x.getMask(); if ((effective & desired) == desired) return true; --- 531,541 ---- int effective = 0; // short circuit if the "*" Permission was added if (all_allowed) { synchronized (this) { ! x = perms.get("*"); } if (x != null) { effective |= x.getMask(); if ((effective & desired) == desired) return true;
*** 548,558 **** String name = pp.getName(); //System.out.println("check "+name); synchronized (this) { ! x = (PropertyPermission) perms.get(name); } if (x != null) { // we have a direct hit! effective |= x.getMask(); --- 548,558 ---- String name = pp.getName(); //System.out.println("check "+name); synchronized (this) { ! x = perms.get(name); } if (x != null) { // we have a direct hit! effective |= x.getMask();
*** 568,578 **** while ((last = name.lastIndexOf(".", offset)) != -1) { name = name.substring(0, last+1) + "*"; //System.out.println("check "+name); synchronized (this) { ! x = (PropertyPermission) perms.get(name); } if (x != null) { effective |= x.getMask(); if ((effective & desired) == desired) --- 568,578 ---- while ((last = name.lastIndexOf(".", offset)) != -1) { name = name.substring(0, last+1) + "*"; //System.out.println("check "+name); synchronized (this) { ! x = perms.get(name); } if (x != null) { effective |= x.getMask(); if ((effective & desired) == desired)
*** 591,604 **** * container. * * @return an enumeration of all the PropertyPermission objects. */ ! public Enumeration elements() { // Convert Iterator of Map values into an Enumeration synchronized (this) { ! return Collections.enumeration(perms.values()); } } private static final long serialVersionUID = 7015263904581634791L; --- 591,604 ---- * container. * * @return an enumeration of all the PropertyPermission objects. */ ! public Enumeration<Permission> elements() { // Convert Iterator of Map values into an Enumeration synchronized (this) { ! return (Enumeration)Collections.enumeration(perms.values()); } } private static final long serialVersionUID = 7015263904581634791L;
*** 631,641 **** */ private void writeObject(ObjectOutputStream out) throws IOException { // Don't call out.defaultWriteObject() // Copy perms into a Hashtable ! Hashtable permissions = new Hashtable(perms.size()*2); synchronized (this) { permissions.putAll(perms); } // Write out serializable fields --- 631,642 ---- */ private void writeObject(ObjectOutputStream out) throws IOException { // Don't call out.defaultWriteObject() // Copy perms into a Hashtable ! Hashtable<String, PropertyPermission> permissions = ! new Hashtable<>(perms.size()*2); synchronized (this) { permissions.putAll(perms); } // Write out serializable fields
*** 658,667 **** // Get all_allowed all_allowed = gfields.get("all_allowed", false); // Get permissions ! Hashtable permissions = (Hashtable)gfields.get("permissions", null); ! perms = new HashMap(permissions.size()*2); perms.putAll(permissions); } } --- 659,670 ---- // Get all_allowed all_allowed = gfields.get("all_allowed", false); // Get permissions ! @SuppressWarnings("unchecked") ! Hashtable<String, PropertyPermission> permissions = ! (Hashtable<String, PropertyPermission>)gfields.get("permissions", null); ! perms = new HashMap<>(permissions.size()*2); perms.putAll(permissions); } }