[NEW BUG][JDK11] Use Collections.emptyEnumeration() where possible (original) (raw)
Christoph Dreis christoph.dreis at freenet.de
Sun May 6 15:19:34 UTC 2018
- Previous message: RFR: 8201274: Launch Single-File Source-Code Programs
- Next message: [NEW BUG][JDK11] Use Collections.emptyEnumeration() where possible
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi,
I just noticed two places - namely in JarFile and JarVerifier - that could make use of Collections.emptyEnumeration().
Let me know what you think. I'd be happy if this is sponsored in case it's considered worthwile.
Cheers, Christoph
============= PATCH ============== diff -r 7238cb613dc5 src/java.base/share/classes/java/util/jar/JarFile.java --- a/src/java.base/share/classes/java/util/jar/JarFile.java Sun May 06 00:42:59 2018 +0200 +++ b/src/java.base/share/classes/java/util/jar/JarFile.java Sun May 06 17:10:42 2018 +0200 @@ -42,6 +42,7 @@ 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 @@ if (includeUnsigned) { return unsignedEntryNames(); } else { - return new Enumeration<>() {
public boolean hasMoreElements() {
return false;
}
public String nextElement() {
throw new NoSuchElementException();
}
};
}return Collections.emptyEnumeration(); }
diff -r 7238cb613dc5 src/java.base/share/classes/java/util/jar/JarVerifier.java --- a/src/java.base/share/classes/java/util/jar/JarVerifier.java Sun May 06 00:42:59 2018 +0200 +++ b/src/java.base/share/classes/java/util/jar/JarVerifier.java Sun May 06 17:10:42 2018 +0200 @@ -684,7 +684,7 @@ }
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 @@ } }; } - private Enumeration emptyEnumeration = new Enumeration() {
public boolean hasMoreElements() {
return false;
}
public String nextElement() {
throw new NoSuchElementException();
}
- };
- Previous message: RFR: 8201274: Launch Single-File Source-Code Programs
- Next message: [NEW BUG][JDK11] Use Collections.emptyEnumeration() where possible
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]