src/share/classes/com/sun/tools/sjavac/BuildState.java

Print this page

        

@@ -24,12 +24,15 @@
  */
 
 package com.sun.tools.sjavac;
 
 import java.io.File;
+import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
 /**
  * The build state class captures the source code and generated artifacts

@@ -46,16 +49,20 @@
     private Map<String,Package> packages = new HashMap<>();
     private Map<String,Source> sources = new HashMap<>();
     private Map<String,File> artifacts = new HashMap<>();
     // Map from package to a set of packages that depend on said package.
     private Map<String,Set<String>> dependents = new HashMap<>();
+    // All Archives that are found to have the same timestamps as in the javac_state file are stored here.
+    // If a archive is not found here, it is either new, or its timestamps has changed.
+    private Set<String> archives = new HashSet<>();
 
     public  Map<String,Module> modules() { return modules; }
     public  Map<String,Package> packages() { return packages; }
     public  Map<String,Source> sources() { return sources; }
     public  Map<String,File> artifacts() { return artifacts; }
     public  Map<String,Set<String>> dependents() { return dependents; }
+    public  Set<String> archives() { return archives; }
 
     /**
      * Lookup a module from a name. Create the module if it does
      * not exist yet.
      */

@@ -260,10 +267,40 @@
         sources.put(s.name(), s);
         return s;
     }
 
     /**
+     * Add to archives, but only if the timestamp is the same, ie the archive is 
+     * probably unchanged.
+     */
+    public void loadArchiveTimestamp(String l) {
+        int p = l.indexOf(' ', 2);
+        String archive = l.substring(2, p);
+        long timestamp = Long.parseLong(l.substring(p+1));
+        File f = new File(archive);
+        if (f.lastModified() == timestamp) {
+            Log.trace("Same timestamp for "+archive);
+            archives.add(archive);
+        } else {
+            Log.debug("Timestamp changed for "+archive);
+        }
+    }
+
+    /**
+     * Save archive with timestamp info.
+     */
+    public void saveArchiveTimestamps(StringBuilder b) {
+        List<String> sorted = new ArrayList<>();
+        sorted.addAll(archives);
+        Collections.sort(sorted);
+        for (String a : sorted) {
+            File f = new File(a);
+            b.append("Z "+a+" "+f.lastModified()+"\n");
+        }
+    }
+
+    /**
      * During an incremental compile we need to copy the old javac state
      * information about packages that were not recompiled.
      */
     public void copyPackagesExcept(BuildState prev, Set<String> recompiled, Set<String> removed) {
         for (String pkg : prev.packages().keySet()) {