Revision: 10331
Author: [email protected]
Date: Tue Jun 14 05:20:58 2011
Log: Crude AST versioning.
http://gwt-code-reviews.appspot.com/1450816/
Review by: [email protected]
http://code.google.com/p/google-web-toolkit/source/detail?r=10331
Modified:
/trunk/dev/core/src/com/google/gwt/dev/javac/CachedCompilationUnit.java
/trunk/dev/core/src/com/google/gwt/dev/javac/PersistentUnitCache.java
/trunk/dev/core/src/com/google/gwt/dev/jjs/impl/GwtAstBuilder.java
=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/javac/CachedCompilationUnit.java
Thu May 12 10:40:46 2011
+++ /trunk/dev/core/src/com/google/gwt/dev/javac/CachedCompilationUnit.java
Tue Jun 14 05:20:58 2011
@@ -15,6 +15,7 @@
*/
package com.google.gwt.dev.javac;
+import com.google.gwt.dev.jjs.impl.GwtAstBuilder;
import com.google.gwt.dev.util.DiskCacheToken;
import org.eclipse.jdt.core.compiler.CategorizedProblem;
@@ -27,6 +28,7 @@
*/
public class CachedCompilationUnit extends CompilationUnit {
private final DiskCacheToken astToken;
+ private final long astVersion;
private final Collection<CompiledClass> compiledClasses;
private final ContentId contentId;
private final Dependencies dependencies;
@@ -64,6 +66,7 @@
this.isSuperSource = unit.isSuperSource();
this.problems = unit.problems;
this.astToken = unit.astToken;
+ this.astVersion = unit.astVersion;
this.sourceToken = unit.sourceToken;
// Override these fields
@@ -106,6 +109,7 @@
}
}
this.astToken = new DiskCacheToken(astToken);
+ this.astVersion = GwtAstBuilder.getSerializationVersion();
this.sourceToken = new DiskCacheToken(sourceToken);
}
@@ -191,4 +195,8 @@
CategorizedProblem[] getProblems() {
return problems;
}
-}
+
+ long getTypesSerializedVersion() {
+ return astVersion;
+ }
+}
=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/javac/PersistentUnitCache.java
Mon Jun 13 07:52:03 2011
+++ /trunk/dev/core/src/com/google/gwt/dev/javac/PersistentUnitCache.java
Tue Jun 14 05:20:58 2011
@@ -17,6 +17,7 @@
import com.google.gwt.core.ext.TreeLogger;
import com.google.gwt.core.ext.UnableToCompleteException;
+import com.google.gwt.dev.jjs.impl.GwtAstBuilder;
import com.google.gwt.dev.util.log.speedtracer.DevModeEventType;
import com.google.gwt.dev.util.log.speedtracer.SpeedTracerLogger;
import com.google.gwt.dev.util.log.speedtracer.SpeedTracerLogger.Event;
@@ -489,10 +490,15 @@
*/
inputStream = new ObjectInputStream(bis);
while (true) {
- CompilationUnit unit = (CompilationUnit)
inputStream.readObject();
+ CachedCompilationUnit unit = (CachedCompilationUnit)
inputStream.readObject();
if (unit == null) {
break;
}
+ if (GwtAstBuilder.ENABLED) {
+ if (unit.getTypesSerializedVersion() !=
GwtAstBuilder.getSerializationVersion()) {
+ continue;
+ }
+ }
UnitCacheEntry entry = new UnitCacheEntry(unit,
UnitOrigin.PERSISTENT);
UnitCacheEntry oldEntry =
unitMap.get(unit.getResourcePath());
if (oldEntry != null && unit.getLastModified() >
oldEntry.getUnit().getLastModified()) {
=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/jjs/impl/GwtAstBuilder.java Mon
Jun 13 12:05:05 2011
+++ /trunk/dev/core/src/com/google/gwt/dev/jjs/impl/GwtAstBuilder.java Tue
Jun 14 05:20:58 2011
@@ -2752,6 +2752,13 @@
public static boolean ENABLED =
System.getProperties().containsKey("x.gwt.astBuilder");
+ /**
+ * Manually tracked version count.
+ *
+ * TODO(zundel): something much more awesome?
+ */
+ private static final long AST_VERSION = 1;
+
private static final char[] _STRING = "_String".toCharArray();
private static final String ARRAY_LENGTH_FIELD = "length";
@@ -2781,6 +2788,16 @@
"Unexpectedly unable to access
ForeachStatement.collectionElementType via reflection", e);
}
}
+
+ /**
+ * Returns a serialization version number. Used to determine if the AST
+ * contained within cached compilation units is compatible with the
current
+ * version of GWT.
+ */
+ public static long getSerializationVersion() {
+ // TODO(zundel): something much awesomer.
+ return ENABLED ? AST_VERSION : 0L;
+ }
static String dotify(char[][] name) {
StringBuffer result = new StringBuffer();
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors