< prev index next >
src/java.base/share/classes/java/security/AlgorithmParameters.java
Print this page
rev 15967 : [mq]: GetInstance
@@ -26,10 +26,11 @@
package java.security;
import java.io.*;
import java.security.spec.AlgorithmParameterSpec;
import java.security.spec.InvalidParameterSpecException;
+import java.util.Objects;
/**
* This class is used as an opaque representation of cryptographic parameters.
*
* <p>An {@code AlgorithmParameters} object for managing the parameters
@@ -138,20 +139,23 @@
* See the AlgorithmParameters section in the <a href=
* "{@docRoot}/../technotes/guides/security/StandardNames.html#AlgorithmParameters">
* Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names.
*
- * @return the new parameter object.
+ * @return the new parameter object
*
- * @exception NoSuchAlgorithmException if no Provider supports an
- * AlgorithmParametersSpi implementation for the
- * specified algorithm.
+ * @throws NoSuchAlgorithmException if no {@code Provider} supports an
+ * {@code AlgorithmParametersSpi} implementation for the
+ * specified algorithm
+ *
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see Provider
*/
public static AlgorithmParameters getInstance(String algorithm)
throws NoSuchAlgorithmException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
try {
Object[] objs = Security.getImpl(algorithm, "AlgorithmParameters",
(String)null);
return new AlgorithmParameters((AlgorithmParametersSpi)objs[0],
(Provider)objs[1],
@@ -182,28 +186,31 @@
* Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names.
*
* @param provider the name of the provider.
*
- * @return the new parameter object.
+ * @return the new parameter object
+ *
+ * @throws IllegalArgumentException if the provider name is {@code null}
+ * or empty
*
- * @exception NoSuchAlgorithmException if an AlgorithmParametersSpi
+ * @throws NoSuchAlgorithmException if an {@code AlgorithmParametersSpi}
* 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 provider name is null
- * or empty.
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see Provider
*/
public static AlgorithmParameters getInstance(String algorithm,
String provider)
throws NoSuchAlgorithmException, NoSuchProviderException
{
+ Objects.requireNonNull(algorithm, "null algorithm name");
if (provider == null || provider.length() == 0)
throw new IllegalArgumentException("missing provider");
Object[] objs = Security.getImpl(algorithm, "AlgorithmParameters",
provider);
return new AlgorithmParameters((AlgorithmParametersSpi)objs[0],
@@ -229,26 +236,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 parameter object.
+ * @return the new parameter object
+ *
+ * @throws IllegalArgumentException if the provider is {@code null}
*
- * @exception NoSuchAlgorithmException if an AlgorithmParameterGeneratorSpi
+ * @throws NoSuchAlgorithmException if an
+ * {@code AlgorithmParameterGeneratorSpi}
* implementation for the specified algorithm is not available
- * from the specified Provider object.
+ * from the specified {@code Provider} object
*
- * @exception IllegalArgumentException if the provider is null.
+ * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see Provider
*
* @since 1.4
*/
public static AlgorithmParameters getInstance(String algorithm,
Provider provider)
throws NoSuchAlgorithmException
{
+ Objects.requireNonNull(algorithm, "null algorithm name");
if (provider == null)
throw new IllegalArgumentException("missing provider");
Object[] objs = Security.getImpl(algorithm, "AlgorithmParameters",
provider);
return new AlgorithmParameters((AlgorithmParametersSpi)objs[0],
< prev index next >