langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/ZipFileIndexCache.java
changeset 27225 8369cde9152a
parent 25874 83c19f00452c
child 27226 53535e4e1b08
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/ZipFileIndexCache.java	Tue Oct 21 09:01:51 2014 -0400
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/ZipFileIndexCache.java	Tue Oct 21 13:08:20 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2014, 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
@@ -25,21 +25,22 @@
 
 package com.sun.tools.javac.file;
 
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 import com.sun.tools.javac.file.RelativePath.RelativeDirectory;
 import com.sun.tools.javac.util.Context;
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
 
 
 /** A cache for ZipFileIndex objects. */
 public class ZipFileIndexCache {
 
-    private final Map<File, ZipFileIndex> map = new HashMap<>();
+    private final Map<Path, ZipFileIndex> map = new HashMap<>();
 
     /** Get a shared instance of the cache. */
     private static ZipFileIndexCache sharedInstance;
@@ -89,13 +90,13 @@
         return zipFileIndexes;
     }
 
-    public synchronized ZipFileIndex getZipFileIndex(File zipFile,
+    public synchronized ZipFileIndex getZipFileIndex(Path zipFile,
             RelativeDirectory symbolFilePrefix,
             boolean useCache, String cacheLocation,
             boolean writeIndex) throws IOException {
         ZipFileIndex zi = getExistingZipIndex(zipFile);
 
-        if (zi == null || (zi != null && zipFile.lastModified() != zi.zipFileLastModified)) {
+        if (zi == null || (zi != null && Files.getLastModifiedTime(zipFile).toMillis() != zi.zipFileLastModified)) {
             zi = new ZipFileIndex(zipFile, symbolFilePrefix, writeIndex,
                     useCache, cacheLocation);
             map.put(zipFile, zi);
@@ -103,7 +104,7 @@
         return zi;
     }
 
-    public synchronized ZipFileIndex getExistingZipIndex(File zipFile) {
+    public synchronized ZipFileIndex getExistingZipIndex(Path zipFile) {
         return map.get(zipFile);
     }
 
@@ -112,7 +113,7 @@
     }
 
     public synchronized void clearCache(long timeNotUsed) {
-        for (File cachedFile : map.keySet()) {
+        for (Path cachedFile : map.keySet()) {
             ZipFileIndex cachedZipIndex = map.get(cachedFile);
             if (cachedZipIndex != null) {
                 long timeToTest = cachedZipIndex.lastReferenceTimeStamp + timeNotUsed;
@@ -124,7 +125,7 @@
         }
     }
 
-    public synchronized void removeFromCache(File file) {
+    public synchronized void removeFromCache(Path file) {
         map.remove(file);
     }