mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8317678: Fix up hashCode() for ZipFile.Source.Key
Reviewed-by: lancea, alanb, jpai
This commit is contained in:
parent
69c0ae23a3
commit
8d9a4b43f4
3 changed files with 189 additions and 1 deletions
|
@ -1395,6 +1395,13 @@ public class ZipFile implements ZipConstants, Closeable {
|
|||
private int[] table; // Hash chain heads: indexes into entries
|
||||
private int tablelen; // number of hash heads
|
||||
|
||||
/**
|
||||
* A class representing a key to a zip file. A key is based
|
||||
* on the file key if available, or the path value if the
|
||||
* file key is not available. The key is also based on the
|
||||
* file's last modified time to allow for cases where a zip
|
||||
* file is re-opened after it has been modified.
|
||||
*/
|
||||
private static class Key {
|
||||
final BasicFileAttributes attrs;
|
||||
File file;
|
||||
|
@ -1409,7 +1416,9 @@ public class ZipFile implements ZipConstants, Closeable {
|
|||
public int hashCode() {
|
||||
long t = utf8 ? 0 : Long.MAX_VALUE;
|
||||
t += attrs.lastModifiedTime().toMillis();
|
||||
return ((int)(t ^ (t >>> 32))) + file.hashCode();
|
||||
Object fk = attrs.fileKey();
|
||||
return Long.hashCode(t) +
|
||||
(fk != null ? fk.hashCode() : file.hashCode());
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue