Patch for interim state of incremental compile.
If a user manually switches GwtAstBuilder on/off, cached units may
not have the AST partial data.
Review at http://gwt-code-reviews.appspot.com/1464804
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@10388 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/dev/javac/CompilationStateBuilder.java b/dev/core/src/com/google/gwt/dev/javac/CompilationStateBuilder.java
index 0f25c04..c620035 100644
--- a/dev/core/src/com/google/gwt/dev/javac/CompilationStateBuilder.java
+++ b/dev/core/src/com/google/gwt/dev/javac/CompilationStateBuilder.java
@@ -340,13 +340,16 @@
*/
public static void addArchive(CompilationUnitArchive module) {
UnitCache unitCache = instance.unitCache;
- for (CompilationUnit unit : module.getUnits().values()) {
- CompilationUnit cachedCompilationUnit = unitCache.find(unit.getResourcePath());
+ for (CachedCompilationUnit archivedUnit : module.getUnits().values()) {
+ if (archivedUnit.getTypesSerializedVersion() != GwtAstBuilder.getSerializationVersion()) {
+ continue;
+ }
+ CompilationUnit cachedCompilationUnit = unitCache.find(archivedUnit.getResourcePath());
// A previously cached unit might be from the persistent cache or another
- // archive
+ // archive.
if (cachedCompilationUnit == null
- || cachedCompilationUnit.getLastModified() < unit.getLastModified()) {
- unitCache.addArchivedUnit(unit);
+ || cachedCompilationUnit.getLastModified() < archivedUnit.getLastModified()) {
+ unitCache.addArchivedUnit(archivedUnit);
}
}
}
diff --git a/dev/core/src/com/google/gwt/dev/javac/CompilationUnitArchive.java b/dev/core/src/com/google/gwt/dev/javac/CompilationUnitArchive.java
index 6cf2468..8de15f4 100644
--- a/dev/core/src/com/google/gwt/dev/javac/CompilationUnitArchive.java
+++ b/dev/core/src/com/google/gwt/dev/javac/CompilationUnitArchive.java
@@ -66,7 +66,7 @@
}
private final String topModuleName;
- private transient Map<String, CompilationUnit> units;
+ private transient Map<String, CachedCompilationUnit> units;
/**
* Create an archive object. Note that data is retained in memory only until
@@ -77,7 +77,7 @@
* {@link com.google.gwt.dev.CompileModule}.
*/
public CompilationUnitArchive(String topModuleName) {
- units = new TreeMap<String, CompilationUnit>();
+ units = new TreeMap<String, CachedCompilationUnit>();
this.topModuleName = topModuleName;
}
@@ -85,10 +85,10 @@
* Add a compilation unit to the archive.
*/
public void addUnit(CompilationUnit unit) {
- units.put(unit.getResourcePath(), unit);
+ units.put(unit.getResourcePath(), unit.asCachedCompilationUnit());
}
- public CompilationUnit findUnit(String resourcePath) {
+ public CachedCompilationUnit findUnit(String resourcePath) {
return units.get(resourcePath);
}
@@ -102,7 +102,7 @@
/**
* Retrieve all units stored in this archive.
*/
- public Map<String, CompilationUnit> getUnits() {
+ public Map<String, CachedCompilationUnit> getUnits() {
return ImmutableMap.copyOf(units);
}
@@ -119,20 +119,20 @@
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
stream.defaultReadObject();
- units = new TreeMap<String, CompilationUnit>();
- CompilationUnit unitsIn[] = (CompilationUnit[]) stream.readObject();
- for (CompilationUnit unit : unitsIn) {
+ units = new TreeMap<String, CachedCompilationUnit>();
+ CachedCompilationUnit unitsIn[] = (CachedCompilationUnit[]) stream.readObject();
+ for (CachedCompilationUnit unit : unitsIn) {
assert unit != null;
addUnit(unit);
}
}
- // CompilationUnits are serialized as a sorted array in order to make sure the
+ // CachedCompilationUnits are serialized as a sorted array in order to make sure the
// output format is deterministic.
private void writeObject(ObjectOutputStream stream) throws IOException {
stream.defaultWriteObject();
- CompilationUnit unitsOut[] = units.values().toArray(new CompilationUnit[units.size()]);
- Arrays.sort(unitsOut, CompilationUnit.COMPARATOR);
+ CachedCompilationUnit unitsOut[] = units.values().toArray(new CachedCompilationUnit[units.size()]);
+ Arrays.sort(unitsOut, CachedCompilationUnit.COMPARATOR);
stream.writeObject(unitsOut);
}
}