diff --git a/jdk/src/share/classes/java/security/Provider.java b/jdk/src/share/classes/java/security/Provider.java index 346aca9474c..2584528a464 100644 --- a/jdk/src/share/classes/java/security/Provider.java +++ b/jdk/src/share/classes/java/security/Provider.java @@ -1376,7 +1376,7 @@ public abstract class Provider extends Properties { *
This class defines the methods {@link #supportsParameter
* supportsParameter()} and {@link #newInstance newInstance()}
* which are used by the Java security framework when it searches for
- * suitable services and instantes them. The valid arguments to those
+ * suitable services and instantiates them. The valid arguments to those
* methods depend on the type of service. For the service types defined
* within Java SE, see the
*
@@ -1566,7 +1566,7 @@ public abstract class Provider extends Properties {
*
* @throws InvalidParameterException if the value of
* constructorParameter is invalid for this type of service.
- * @throws NoSuchAlgorithmException if instantation failed for
+ * @throws NoSuchAlgorithmException if instantiation failed for
* any other reason.
*/
public Object newInstance(Object constructorParameter)
@@ -1594,7 +1594,9 @@ public abstract class Provider extends Properties {
+ " engines");
}
Class> clazz = getImplClass();
- return clazz.newInstance();
+ Class>[] empty = {};
+ Constructor> con = clazz.getConstructor(empty);
+ return con.newInstance();
} else {
Class> paramClass = cap.getConstructorParameterClass();
if (constructorParameter != null) {
@@ -1637,13 +1639,18 @@ public abstract class Provider extends Properties {
} else {
clazz = cl.loadClass(className);
}
+ if (!Modifier.isPublic(clazz.getModifiers())) {
+ throw new NoSuchAlgorithmException
+ ("class configured for " + type + " (provider: " +
+ provider.getName() + ") is not public.");
+ }
classRef = new WeakReference