classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] [generics] Patch: FYI: genericize java.security


From: Tom Tromey
Subject: [cp-patches] [generics] Patch: FYI: genericize java.security
Date: Fri, 25 Nov 2005 14:23:07 -0700

I'm checking this in on the generics branch.

This genericizes java.security.  I did a fairly shallow
genericization, I think warning cleanups should probably come later,
to reduce the amount of merge work in the meantime.

Tom

2005-11-25  Tom Tromey  <address@hidden>

        * java/security/Security.java (getAlgorithms): Genericized.
        (getProviders): Likewise.
        * java/security/SecureClassLoader.java (defineClass): Genericized.
        (protectionDomainCache): Likewise.
        * java/security/PermissionCollection.java (elements): Genericized.
        (toString): Updated.
        * java/security/KeyStoreSpi.java (engineAliases): Genericized.
        * java/security/KeyStore.java (aliases): Genericized.
        * java/security/KeyFactorySpi.java (engineGetKeySpec): Genericized.
        (engineTranslateKey): Fixed javadoc.
        * java/security/KeyFactory.java (getKeySpec): Genericized.
        * java/security/IdentityScope.java (identities): Genericized.
        * java/security/AlgorithmParametersSpi.java (engineGetParameterSpec):
        Genericized.
        * java/security/AlgorithmParameters.java (getParameterSpec):
        Genericized.
        * java/security/AccessController.java (doPrivileged): Genericized.
        * java/security/PrivilegedExceptionAction.java: Genericized.
        * java/security/PrivilegedAction.java: Genericized.

Index: java/security/AccessController.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/security/AccessController.java,v
retrieving revision 1.8.2.3
diff -u -r1.8.2.3 AccessController.java
--- java/security/AccessController.java 2 Nov 2005 00:43:36 -0000       1.8.2.3
+++ java/security/AccessController.java 25 Nov 2005 21:31:40 -0000
@@ -88,7 +88,7 @@
    * should be be called.
    * @return the result of the <code>action.run()</code> method.
    */
-  public static Object doPrivileged(PrivilegedAction action)
+  public static <T> T doPrivileged(PrivilegedAction<T> action)
   {
     VMAccessController.pushContext(null);
     try
@@ -115,8 +115,8 @@
    * domains should be added to the protection domain of the calling class.
    * @return the result of the <code>action.run()</code> method.
    */
-  public static Object doPrivileged(PrivilegedAction action,
-                                    AccessControlContext context)
+  public static <T> T doPrivileged(PrivilegedAction<T> action,
+                                   AccessControlContext context)
   {
     VMAccessController.pushContext(context);
     try
@@ -145,7 +145,7 @@
    * @exception PrivilegedActionException wrapped around any checked exception
    * that is thrown in the <code>run()</code> method.
    */
-  public static Object doPrivileged(PrivilegedExceptionAction action)
+  public static <T> T doPrivileged(PrivilegedExceptionAction<T> action)
     throws PrivilegedActionException
   {
     VMAccessController.pushContext(null);
@@ -185,8 +185,8 @@
    * @exception PrivilegedActionException wrapped around any checked exception
    * that is thrown in the <code>run()</code> method.
    */
-  public static Object doPrivileged(PrivilegedExceptionAction action,
-                                    AccessControlContext context)
+  public static <T> T doPrivileged(PrivilegedExceptionAction<T> action,
+                                   AccessControlContext context)
     throws PrivilegedActionException
   {
     VMAccessController.pushContext(context);
Index: java/security/AlgorithmParameters.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/security/AlgorithmParameters.java,v
retrieving revision 1.9.2.3
diff -u -r1.9.2.3 AlgorithmParameters.java
--- java/security/AlgorithmParameters.java      2 Aug 2005 20:12:24 -0000       
1.9.2.3
+++ java/security/AlgorithmParameters.java      25 Nov 2005 21:31:40 -0000
@@ -291,7 +291,8 @@
    * specification is inappropriate for this parameter object, or if this
    * parameter object has not been initialized.
    */
-  public final AlgorithmParameterSpec getParameterSpec(Class paramSpec)
+  public final <T extends AlgorithmParameterSpec>
+  T getParameterSpec(Class<T> paramSpec)
     throws InvalidParameterSpecException
   {
     return paramSpi.engineGetParameterSpec(paramSpec);
Index: java/security/AlgorithmParametersSpi.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/java/security/AlgorithmParametersSpi.java,v
retrieving revision 1.4.2.2
diff -u -r1.4.2.2 AlgorithmParametersSpi.java
--- java/security/AlgorithmParametersSpi.java   2 Aug 2005 20:12:24 -0000       
1.4.2.2
+++ java/security/AlgorithmParametersSpi.java   25 Nov 2005 21:31:40 -0000
@@ -113,8 +113,8 @@
    * @throws InvalidParameterSpecException if the paramSpec is an
    * invalid parameter class
    */
-  protected abstract AlgorithmParameterSpec engineGetParameterSpec(Class
-                                                                  paramSpec)
+  protected abstract <T extends AlgorithmParameterSpec> 
+  T engineGetParameterSpec(Class<T> paramSpec)
     throws InvalidParameterSpecException;
 
 
Index: java/security/IdentityScope.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/security/IdentityScope.java,v
retrieving revision 1.8.2.2
diff -u -r1.8.2.2 IdentityScope.java
--- java/security/IdentityScope.java    2 Aug 2005 20:12:24 -0000       1.8.2.2
+++ java/security/IdentityScope.java    25 Nov 2005 21:31:40 -0000
@@ -210,7 +210,7 @@
    *
    * @return an enumeration of all identities in this identity scope.
    */
-  public abstract Enumeration identities();
+  public abstract Enumeration<Identity> identities();
 
   /**
    * Returns a string representation of this identity scope, including its 
name,
Index: java/security/KeyFactory.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/security/KeyFactory.java,v
retrieving revision 1.8.2.3
diff -u -r1.8.2.3 KeyFactory.java
--- java/security/KeyFactory.java       2 Aug 2005 20:12:24 -0000       1.8.2.3
+++ java/security/KeyFactory.java       25 Nov 2005 21:31:40 -0000
@@ -275,7 +275,7 @@
    * inappropriate for the given key, or the given key cannot be processed
    * (e.g., the given key has an unrecognized algorithm or format).
    */
-  public final KeySpec getKeySpec(Key key, Class keySpec)
+  public final <T extends KeySpec> T getKeySpec(Key key, Class<T> keySpec)
     throws InvalidKeySpecException
   {
     return keyFacSpi.engineGetKeySpec(key, keySpec);
Index: java/security/KeyFactorySpi.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/security/KeyFactorySpi.java,v
retrieving revision 1.4.2.2
diff -u -r1.4.2.2 KeyFactorySpi.java
--- java/security/KeyFactorySpi.java    2 Aug 2005 20:12:24 -0000       1.4.2.2
+++ java/security/KeyFactorySpi.java    25 Nov 2005 21:31:40 -0000
@@ -113,7 +113,8 @@
    * is inappropriate for this key or the key is 
    * unrecognized.
    */
-  protected abstract KeySpec engineGetKeySpec(Key key, Class keySpec)
+  protected abstract <T extends KeySpec> T engineGetKeySpec(Key key,
+                                                            Class<T> keySpec)
     throws InvalidKeySpecException;
 
 
@@ -121,11 +122,11 @@
    * Translates the key from an unknown or untrusted provider
    * into a key for this key factory.
    *
-   * @param the key from an unknown or untrusted provider
+   * @param key key from an unknown or untrusted provider
    *
    * @return the translated key
    *
-   * @throws InvalidKeySpecException if the key cannot be 
+   * @throws InvalidKeyException if the key cannot be 
    * processed by this key factory
    */
   protected abstract Key engineTranslateKey(Key key)
Index: java/security/KeyStore.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/security/KeyStore.java,v
retrieving revision 1.8.2.3
diff -u -r1.8.2.3 KeyStore.java
--- java/security/KeyStore.java 2 Aug 2005 20:12:24 -0000       1.8.2.3
+++ java/security/KeyStore.java 25 Nov 2005 21:31:41 -0000
@@ -392,7 +392,7 @@
 
      @return an Enumeration of the aliases
    */
-  public final Enumeration aliases() throws KeyStoreException
+  public final Enumeration<String> aliases() throws KeyStoreException
   {
     return keyStoreSpi.engineAliases();
   }
Index: java/security/KeyStoreSpi.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/security/KeyStoreSpi.java,v
retrieving revision 1.4.2.2
diff -u -r1.4.2.2 KeyStoreSpi.java
--- java/security/KeyStoreSpi.java      2 Aug 2005 20:12:25 -0000       1.4.2.2
+++ java/security/KeyStoreSpi.java      25 Nov 2005 21:31:41 -0000
@@ -187,7 +187,7 @@
    *
    * @return an Enumeration of the aliases
    */
-  public abstract Enumeration engineAliases();
+  public abstract Enumeration<String> engineAliases();
 
   /**
    * Determines if the keystore contains the specified alias.
Index: java/security/PermissionCollection.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/security/PermissionCollection.java,v
retrieving revision 1.8.2.2
diff -u -r1.8.2.2 PermissionCollection.java
--- java/security/PermissionCollection.java     2 Aug 2005 20:12:25 -0000       
1.8.2.2
+++ java/security/PermissionCollection.java     25 Nov 2005 21:31:41 -0000
@@ -120,7 +120,7 @@
    *
    * @return an <code>Enumeration</code> of this collection's objects
    */
-  public abstract Enumeration elements();
+  public abstract Enumeration<Permission> elements();
 
   /**
    * This method sets this <code>PermissionCollection</code> object to be
@@ -159,7 +159,7 @@
     StringBuffer sb = new StringBuffer(super.toString());
 
     sb.append(" (\n");
-    Enumeration e = elements();
+    Enumeration<Permission> e = elements();
     while (e.hasMoreElements())
       sb.append(' ').append(e.nextElement()).append('\n');
     return sb.append(")\n").toString();
Index: java/security/PrivilegedAction.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/security/PrivilegedAction.java,v
retrieving revision 1.5.2.1
diff -u -r1.5.2.1 PrivilegedAction.java
--- java/security/PrivilegedAction.java 2 Aug 2005 20:12:25 -0000       1.5.2.1
+++ java/security/PrivilegedAction.java 25 Nov 2005 21:31:41 -0000
@@ -47,9 +47,9 @@
  * @see AccessController
  * @see PrivilegedExceptionAction
  * @since 1.1
- * @status updated to 1.4
+ * @status updated to 1.5
  */
-public interface PrivilegedAction
+public interface PrivilegedAction<T>
 {
   /**
    * This method performs an operation that requires higher privileges to
@@ -60,5 +60,5 @@
    * @see AccessController#doPrivileged(PrivilegedAction)
    * @see AccessController#doPrivileged(PrivilegedAction, AccessControlContext)
    */
-  Object run();
+  T run();
 } // interface PrivilegedAction
Index: java/security/PrivilegedExceptionAction.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/java/security/PrivilegedExceptionAction.java,v
retrieving revision 1.5.2.1
diff -u -r1.5.2.1 PrivilegedExceptionAction.java
--- java/security/PrivilegedExceptionAction.java        2 Aug 2005 20:12:25 
-0000       1.5.2.1
+++ java/security/PrivilegedExceptionAction.java        25 Nov 2005 21:31:41 
-0000
@@ -46,9 +46,9 @@
  *
  * @author Aaron M. Renn (address@hidden)
  * @since 1.1
- * @status updated to 1.4
+ * @status updated to 1.5
  */
-public interface PrivilegedExceptionAction
+public interface PrivilegedExceptionAction<T>
 {
   /**
    * This method performs an operation that requires higher privileges to
@@ -61,5 +61,5 @@
    * @see AccessController#doPrivileged(PrivilegedExceptionAction,
    *                                    AccessControlContext)
    */
-  Object run() throws Exception;
+  T run() throws Exception;
 } // interface PrivilegedExceptionAction
Index: java/security/SecureClassLoader.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/security/SecureClassLoader.java,v
retrieving revision 1.11.2.2
diff -u -r1.11.2.2 SecureClassLoader.java
--- java/security/SecureClassLoader.java        2 Aug 2005 20:12:25 -0000       
1.11.2.2
+++ java/security/SecureClassLoader.java        25 Nov 2005 21:31:41 -0000
@@ -37,6 +37,8 @@
 
 package java.security;
 
+import java.util.WeakHashMap;
+
 /**
  * A Secure Class Loader for loading classes with additional 
  * support for specifying code source and permissions when
@@ -48,7 +50,8 @@
  */
 public class SecureClassLoader extends ClassLoader
 {
-  java.util.WeakHashMap protectionDomainCache = new java.util.WeakHashMap();
+  WeakHashMap<CodeSource, ProtectionDomain> protectionDomainCache
+    = new WeakHashMap<CodeSource, ProtectionDomain>();
 
   protected SecureClassLoader(ClassLoader parent)
   {
@@ -79,7 +82,7 @@
    *
    * @exception ClassFormatError if the byte array is not in proper classfile 
format.
    */
-  protected final Class defineClass(String name, byte[] b, int off, int len,
+  protected final Class<?> defineClass(String name, byte[] b, int off, int len,
                                    CodeSource cs)
   {
     if (cs != null)
Index: java/security/Security.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/security/Security.java,v
retrieving revision 1.30.2.5
diff -u -r1.30.2.5 Security.java
--- java/security/Security.java 20 Sep 2005 18:46:29 -0000      1.30.2.5
+++ java/security/Security.java 25 Nov 2005 21:31:41 -0000
@@ -431,9 +431,9 @@
    * no provider supports the specified service.
    * @since 1.4
    */
-  public static Set getAlgorithms(String serviceName)
+  public static Set<String> getAlgorithms(String serviceName)
   {
-    HashSet result = new HashSet();
+    HashSet<String> result = new HashSet<String>();
     if (serviceName == null || serviceName.length() == 0)
       return result;
 
@@ -570,7 +570,7 @@
   * format.
   * @see #getProviders(String)
   */
-  public static Provider[] getProviders(Map filter)
+  public static Provider[] getProviders(Map<String, String> filter)
   {
     if (providers == null || providers.isEmpty())
       return null;
@@ -578,7 +578,7 @@
     if (filter == null)
       return getProviders();
 
-    Set querries = filter.keySet();
+    Set<String> querries = filter.keySet();
     if (querries == null || querries.isEmpty())
       return getProviders();
 
@@ -601,7 +601,7 @@
           throw new InvalidParameterException(
               "missing dot in '" + String.valueOf(querry)+"'");
 
-        value = (String) filter.get(querry);
+        value = filter.get(querry);
         // deconstruct querry into [service, algorithm, attribute]
         if (value == null || value.trim().length() == 0) // 
<service>.<algorithm>
           {





reply via email to

[Prev in Thread] Current Thread [Next in Thread]