8202719: Use Collections.emptyEnumeration where possible

Reviewed-by: martin, psandoz
This commit is contained in:
Christoph Dreis 2018-05-08 09:57:45 +02:00 committed by Claes Redestad
parent 13ce1152a4
commit 59d4a62f42
2 changed files with 3 additions and 21 deletions

View file

@ -42,6 +42,7 @@ import java.security.CodeSigner;
import java.security.CodeSource;
import java.security.cert.Certificate;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;
import java.util.Locale;
@ -1095,16 +1096,7 @@ class JarFile extends ZipFile {
if (includeUnsigned) {
return unsignedEntryNames();
} else {
return new Enumeration<>() {
public boolean hasMoreElements() {
return false;
}
public String nextElement() {
throw new NoSuchElementException();
}
};
return Collections.emptyEnumeration();
}
}

View file

@ -684,7 +684,7 @@ class JarVerifier {
}
final List<CodeSigner[]> signersReq = req;
final Enumeration<String> enum2 = (matchUnsigned) ? unsignedEntryNames(jar) : emptyEnumeration;
final Enumeration<String> enum2 = matchUnsigned ? unsignedEntryNames(jar) : Collections.emptyEnumeration();
return new Enumeration<>() {
@ -769,16 +769,6 @@ class JarVerifier {
}
};
}
private Enumeration<String> emptyEnumeration = new Enumeration<String>() {
public boolean hasMoreElements() {
return false;
}
public String nextElement() {
throw new NoSuchElementException();
}
};
// true if file is part of the signature mechanism itself
static boolean isSigningRelated(String name) {