Skip to content
Permalink
Browse files
8268873: Unnecessary Vector usage in java.base
Reviewed-by: mullan
  • Loading branch information
turbanoff authored and Sean Mullan committed Jul 26, 2021
1 parent 0b12e7c commit b8f79a7ff798d3a0eee03a8153be942401781bbc
@@ -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 void write(OutputStream out) throws IOException {
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"));
@@ -39,12 +39,10 @@
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 @@
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 @@
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;
@@ -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 SignerInfo verify(SignerInfo info, byte[] bytes)
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;
}

1 comment on commit b8f79a7

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on b8f79a7 Jul 26, 2021

Please sign in to comment.