8323624: ProviderList.ServiceList does not need to be a list

Reviewed-by: mullan
This commit is contained in:
Weijun Wang 2024-03-29 15:23:26 +00:00
parent 418deaf5a1
commit 59c2aff1ed
12 changed files with 70 additions and 131 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2024, 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
@ -131,8 +131,7 @@ public class KeyFactory {
private KeyFactory(String algorithm) throws NoSuchAlgorithmException {
this.algorithm = algorithm;
List<Service> list = GetInstance.getServices("KeyFactory", algorithm);
serviceIterator = list.iterator();
serviceIterator = GetInstance.getServices("KeyFactory", algorithm);
// fetch and instantiate initial spi
if (nextSpi(null) == null) {
throw new NoSuchAlgorithmException

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2024, 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
@ -230,9 +230,7 @@ public abstract class KeyPairGenerator extends KeyPairGeneratorSpi {
public static KeyPairGenerator getInstance(String algorithm)
throws NoSuchAlgorithmException {
Objects.requireNonNull(algorithm, "null algorithm name");
List<Service> list =
GetInstance.getServices("KeyPairGenerator", algorithm);
Iterator<Service> t = list.iterator();
Iterator<Service> t = GetInstance.getServices("KeyPairGenerator", algorithm);
if (!t.hasNext()) {
throw new NoSuchAlgorithmException
(algorithm + " KeyPairGenerator not available");

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2024, 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
@ -257,13 +257,12 @@ public abstract class Signature extends SignatureSpi {
public static Signature getInstance(String algorithm)
throws NoSuchAlgorithmException {
Objects.requireNonNull(algorithm, "null algorithm name");
List<Service> list;
Iterator<Service> t;
if (algorithm.equalsIgnoreCase(RSA_SIGNATURE)) {
list = GetInstance.getServices(rsaIds);
t = GetInstance.getServices(rsaIds);
} else {
list = GetInstance.getServices("Signature", algorithm);
t = GetInstance.getServices("Signature", algorithm);
}
Iterator<Service> t = list.iterator();
if (!t.hasNext()) {
throw new NoSuchAlgorithmException
(algorithm + " Signature not available");