< prev index next >

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

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, 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

@@ -23,24 +23,25 @@
  * questions.
  */
 
 package java.security;
 
-import java.io.InvalidObjectException;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.ObjectStreamField;
-import java.io.Serializable;
 import java.util.Enumeration;
-import java.util.HashMap;
 import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
 import java.util.NoSuchElementException;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Iterator;
+import java.util.Collections;
 import java.util.concurrent.ConcurrentHashMap;
+import java.io.Serializable;
+import java.io.ObjectStreamField;
+import java.io.ObjectOutputStream;
+import java.io.ObjectInputStream;
+import java.io.IOException;
+
 
 /**
  * This class represents a heterogeneous collection of Permissions. That is,
  * it contains different types of Permission objects, organized into
  * PermissionCollections. For example, if any

@@ -389,26 +390,10 @@
         Hashtable<Class<?>, PermissionCollection> perms =
             (Hashtable<Class<?>, PermissionCollection>)gfields.get("perms", null);
         permsMap = new ConcurrentHashMap<>(perms.size()*2);
         permsMap.putAll(perms);
 
-        // Check that Class is mapped to PermissionCollection containing
-        // Permissions of the same class
-        for (Map.Entry<Class<?>, PermissionCollection> e : perms.entrySet()) {
-            Class<?> k = e.getKey();
-            PermissionCollection v = e.getValue();
-            Enumeration<Permission> en = v.elements();
-            while (en.hasMoreElements()) {
-                Permission p = en.nextElement();
-                if (!k.equals(p.getClass())) {
-                    throw new InvalidObjectException("Permission with class " +
-                        k + " incorrectly mapped to PermissionCollection " +
-                        "containing Permission with " + p.getClass());
-                }
-            }
-        }
-
         // Set hasUnresolved
         UnresolvedPermissionCollection uc =
         (UnresolvedPermissionCollection) permsMap.get(UnresolvedPermission.class);
         hasUnresolved = (uc != null && uc.elements().hasMoreElements());
     }

@@ -597,17 +582,7 @@
         @SuppressWarnings("unchecked")
         Hashtable<Permission, Permission> perms =
                 (Hashtable<Permission, Permission>)gfields.get("perms", null);
         permsMap = new ConcurrentHashMap<>(perms.size()*2);
         permsMap.putAll(perms);
-
-        // check that the Permission key and value are the same object
-        for (Map.Entry<Permission, Permission> e : perms.entrySet()) {
-            Permission k = e.getKey();
-            Permission v = e.getValue();
-            if (k != v) {
-                throw new InvalidObjectException("Permission (" + k +
-                    ") incorrectly mapped to Permission (" + v + ")");
-            }
-        }
     }
 }
< prev index next >