8268873: Unnecessary Vector usage in java.base

Reviewed-by: mullan
This commit is contained in:
Andrey Turbanov 2021-07-26 18:18:56 +00:00 committed by Sean Mullan
parent 0b12e7c82c
commit b8f79a7ff7
3 changed files with 14 additions and 17 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2021, 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
@ -284,11 +284,11 @@ public class JarIndex {
public void read(InputStream is) throws IOException {
BufferedReader br = new BufferedReader
(new InputStreamReader(is, UTF_8.INSTANCE));
String line = null;
String line;
String currentJar = null;
/* an ordered list of jar file names */
Vector<String> jars = new Vector<>();
ArrayList<String> jars = new ArrayList<>();
/* read until we see a .jar line */
while((line = br.readLine()) != null && !line.endsWith(".jar"));

View File

@ -39,12 +39,10 @@ import java.net.InetSocketAddress;
import java.net.Proxy;
import java.security.Principal;
import java.security.cert.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.StringTokenizer;
import java.util.Vector;
import javax.security.auth.x500.X500Principal;
import javax.net.ssl.*;
import sun.net.www.http.HttpClient;
@ -148,14 +146,14 @@ final class HttpsClient extends HttpClient
ciphers = null;
} else {
StringTokenizer tokenizer;
Vector<String> v = new Vector<String>();
ArrayList<String> v = new ArrayList<>();
tokenizer = new StringTokenizer(cipherString, ",");
while (tokenizer.hasMoreTokens())
v.addElement(tokenizer.nextToken());
v.add(tokenizer.nextToken());
ciphers = new String [v.size()];
for (int i = 0; i < ciphers.length; i++)
ciphers [i] = v.elementAt(i);
ciphers [i] = v.get(i);
}
return ciphers;
}
@ -172,14 +170,14 @@ final class HttpsClient extends HttpClient
protocols = null;
} else {
StringTokenizer tokenizer;
Vector<String> v = new Vector<String>();
ArrayList<String> v = new ArrayList<>();
tokenizer = new StringTokenizer(protocolString, ",");
while (tokenizer.hasMoreTokens())
v.addElement(tokenizer.nextToken());
v.add(tokenizer.nextToken());
protocols = new String [v.size()];
for (int i = 0; i < protocols.length; i++) {
protocols [i] = v.elementAt(i);
protocols [i] = v.get(i);
}
}
return protocols;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2021, 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
@ -578,19 +578,18 @@ public class PKCS7 {
public SignerInfo[] verify(byte[] bytes)
throws NoSuchAlgorithmException, SignatureException {
Vector<SignerInfo> intResult = new Vector<>();
ArrayList<SignerInfo> intResult = new ArrayList<>();
for (int i = 0; i < signerInfos.length; i++) {
SignerInfo signerInfo = verify(signerInfos[i], bytes);
if (signerInfo != null) {
intResult.addElement(signerInfo);
intResult.add(signerInfo);
}
}
if (!intResult.isEmpty()) {
SignerInfo[] result = new SignerInfo[intResult.size()];
intResult.copyInto(result);
return result;
return intResult.toArray(result);
}
return null;
}