--- old/src/share/classes/com/sun/tools/sjavac/BuildState.java 2014-08-09 00:28:43.323985590 +0200 +++ new/src/share/classes/com/sun/tools/sjavac/BuildState.java 2014-08-09 00:28:43.203989074 +0200 @@ -26,8 +26,11 @@ 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; @@ -48,12 +51,16 @@ private Map artifacts = new HashMap<>(); // Map from package to a set of packages that depend on said package. private Map> 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 archives = new HashSet<>(); public Map modules() { return modules; } public Map packages() { return packages; } public Map sources() { return sources; } public Map artifacts() { return artifacts; } public Map> dependents() { return dependents; } + public Set archives() { return archives; } /** * Lookup a module from a name. Create the module if it does @@ -262,6 +269,36 @@ } /** + * 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 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. */