< prev index next >

src/java.base/share/classes/javax/crypto/KeyGenerator.java

Print this page
rev 15967 : [mq]: GetInstance

@@ -214,22 +214,23 @@
      * See the KeyGenerator section in the <a href=
      * "{@docRoot}/../technotes/guides/security/StandardNames.html#KeyGenerator">
      * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
      * for information about standard algorithm names.
      *
-     * @return the new {@code KeyGenerator} object.
+     * @return the new {@code KeyGenerator} object
      *
-     * @exception NullPointerException if the specified algorithm is null.
+     * @throws NoSuchAlgorithmException if no {@code Provider} supports a
+     *         {@code KeyGeneratorSpi} implementation for the
+     *         specified algorithm
      *
-     * @exception NoSuchAlgorithmException if no Provider supports a
-     *          KeyGeneratorSpi implementation for the
-     *          specified algorithm.
+     * @throws NullPointerException if {@code algorithm} is {@code null}
      *
      * @see java.security.Provider
      */
     public static final KeyGenerator getInstance(String algorithm)
             throws NoSuchAlgorithmException {
+        Objects.requireNonNull(algorithm, "null algorithm name");
         return new KeyGenerator(algorithm);
     }
 
     /**
      * Returns a {@code KeyGenerator} object that generates secret keys

@@ -249,29 +250,30 @@
      * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
      * for information about standard algorithm names.
      *
      * @param provider the name of the provider.
      *
-     * @return the new {@code KeyGenerator} object.
+     * @return the new {@code KeyGenerator} object
      *
-     * @exception NullPointerException if the specified algorithm is null.
+     * @throws IllegalArgumentException if the {@code provider}
+     *         is {@code null} or empty
      *
-     * @exception NoSuchAlgorithmException if a KeyGeneratorSpi
+     * @throws NoSuchAlgorithmException if a {@code KeyGeneratorSpi}
      *          implementation for the specified algorithm is not
-     *          available from the specified provider.
+     *         available from the specified provider
      *
-     * @exception NoSuchProviderException if the specified provider is not
-     *          registered in the security provider list.
+     * @throws NoSuchProviderException if the specified provider is not
+     *         registered in the security provider list
      *
-     * @exception IllegalArgumentException if the {@code provider}
-     *          is null or empty.
+     * @throws NullPointerException if {@code algorithm} is {@code null}
      *
      * @see java.security.Provider
      */
     public static final KeyGenerator getInstance(String algorithm,
             String provider) throws NoSuchAlgorithmException,
             NoSuchProviderException {
+        Objects.requireNonNull(algorithm, "null algorithm name");
         Instance instance = JceSecurity.getInstance("KeyGenerator",
                 KeyGeneratorSpi.class, algorithm, provider);
         return new KeyGenerator((KeyGeneratorSpi)instance.impl,
                 instance.provider, algorithm);
     }

@@ -291,25 +293,26 @@
      * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
      * for information about standard algorithm names.
      *
      * @param provider the provider.
      *
-     * @return the new {@code KeyGenerator} object.
+     * @return the new {@code KeyGenerator} object
      *
-     * @exception NullPointerException if the specified algorithm is null.
+     * @throws IllegalArgumentException if the {@code provider}
+     *         is {@code null}
      *
-     * @exception NoSuchAlgorithmException if a KeyGeneratorSpi
+     * @throws NoSuchAlgorithmException if a {@code KeyGeneratorSpi}
      *          implementation for the specified algorithm is not available
-     *          from the specified Provider object.
+     *         from the specified {@code Provider} object
      *
-     * @exception IllegalArgumentException if the {@code provider}
-     *          is null.
+     * @throws NullPointerException if {@code algorithm} is {@code null}
      *
      * @see java.security.Provider
      */
     public static final KeyGenerator getInstance(String algorithm,
             Provider provider) throws NoSuchAlgorithmException {
+        Objects.requireNonNull(algorithm, "null algorithm name");
         Instance instance = JceSecurity.getInstance("KeyGenerator",
                 KeyGeneratorSpi.class, algorithm, provider);
         return new KeyGenerator((KeyGeneratorSpi)instance.impl,
                 instance.provider, algorithm);
     }
< prev index next >