Big refactoring of test code and api-checker to remove dependencies on CompilationUnit.

This is in preparation for more refactoring, which will make CompilationUnit stateless outputs rather than stateful inputs/outputs.

Review by: bobv, amitmanjhi, rjrjr

git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@6783 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/dev/javac/CompilationState.java b/dev/core/src/com/google/gwt/dev/javac/CompilationState.java
index 72ec638..61b202d 100644
--- a/dev/core/src/com/google/gwt/dev/javac/CompilationState.java
+++ b/dev/core/src/com/google/gwt/dev/javac/CompilationState.java
@@ -19,6 +19,7 @@
 import com.google.gwt.core.ext.typeinfo.TypeOracle;
 import com.google.gwt.dev.javac.CompilationUnit.State;
 import com.google.gwt.dev.javac.StandardGeneratorContext.Generated;
+import com.google.gwt.dev.javac.impl.Shared;
 import com.google.gwt.dev.javac.impl.SourceFileCompilationUnit;
 import com.google.gwt.dev.js.ast.JsProgram;
 import com.google.gwt.dev.resource.Resource;
@@ -409,7 +410,7 @@
 
     // Then add any new source files.
     for (Resource newSourceFile : changed) {
-      String typeName = SourceFileCompilationUnit.getTypeName(newSourceFile);
+      String typeName = Shared.getTypeName(newSourceFile);
       assert (!unitMap.containsKey(typeName));
       unitMap.put(typeName, new SourceFileCompilationUnit(newSourceFile));
       // invalid a graveyard unit, if a new unit has the same type.
diff --git a/dev/core/src/com/google/gwt/dev/javac/CompilationStateBuilder.java b/dev/core/src/com/google/gwt/dev/javac/CompilationStateBuilder.java
new file mode 100644
index 0000000..5f087b6
--- /dev/null
+++ b/dev/core/src/com/google/gwt/dev/javac/CompilationStateBuilder.java
@@ -0,0 +1,71 @@
+/*

+ * Copyright 2009 Google Inc.

+ * 

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not

+ * use this file except in compliance with the License. You may obtain a copy of

+ * the License at

+ * 

+ * http://www.apache.org/licenses/LICENSE-2.0

+ * 

+ * Unless required by applicable law or agreed to in writing, software

+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT

+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the

+ * License for the specific language governing permissions and limitations under

+ * the License.

+ */

+package com.google.gwt.dev.javac;

+

+import com.google.gwt.core.ext.TreeLogger;

+import com.google.gwt.dev.resource.Resource;

+import com.google.gwt.dev.resource.ResourceOracle;

+

+import java.util.Collections;

+import java.util.HashMap;

+import java.util.Map;

+import java.util.Set;

+

+/**

+ * Mocked out for now.

+ */

+public class CompilationStateBuilder {

+  private static final CompilationStateBuilder instance = new CompilationStateBuilder();

+

+  public static CompilationState buildFrom(TreeLogger logger,

+      Set<Resource> resources) {

+    return instance.doBuildFrom(logger, resources);

+  }

+

+  public static CompilationStateBuilder get() {

+    return instance;

+  }

+

+  public synchronized CompilationState doBuildFrom(TreeLogger logger,

+      final Set<Resource> resources) {

+    final Map<String, Resource> resourceMap = new HashMap<String, Resource>();

+    for (Resource resource : resources) {

+      resourceMap.put(resource.getPath(), resource);

+    }

+

+    final Set<Resource> finalResources = Collections.unmodifiableSet(resources);

+    final Map<String, Resource> finalMap = Collections.unmodifiableMap(resourceMap);

+    ResourceOracle oracle = new ResourceOracle() {

+      public void clear() {

+        throw new UnsupportedOperationException();

+      }

+

+      public Set<String> getPathNames() {

+        return finalMap.keySet();

+      }

+

+      public Map<String, Resource> getResourceMap() {

+        return finalMap;

+      }

+

+      public Set<Resource> getResources() {

+        return finalResources;

+      }

+

+    };

+    return new CompilationState(logger, oracle);

+  }

+}

diff --git a/dev/core/src/com/google/gwt/dev/javac/GeneratedUnit.java b/dev/core/src/com/google/gwt/dev/javac/GeneratedUnit.java
new file mode 100644
index 0000000..a468f77
--- /dev/null
+++ b/dev/core/src/com/google/gwt/dev/javac/GeneratedUnit.java
@@ -0,0 +1,48 @@
+/*

+ * Copyright 2009 Google Inc.

+ * 

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not

+ * use this file except in compliance with the License. You may obtain a copy of

+ * the License at

+ * 

+ * http://www.apache.org/licenses/LICENSE-2.0

+ * 

+ * Unless required by applicable law or agreed to in writing, software

+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT

+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the

+ * License for the specific language governing permissions and limitations under

+ * the License.

+ */

+package com.google.gwt.dev.javac;

+

+/**

+ * A generated Java compilation unit.

+ */

+public class GeneratedUnit {

+

+  public long creationTime() {

+    // TODO Auto-generated method stub

+    return 0;

+  }

+

+  public String getSource() {

+    // TODO Auto-generated method stub

+    return null;

+  }

+

+  public String getStrongHash() {

+    // TODO Auto-generated method stub

+    return null;

+  }

+

+  public String getTypeName() {

+    // TODO Auto-generated method stub

+    return null;

+  }

+

+  public String optionalFileLocation() {

+    // TODO Auto-generated method stub

+    return null;

+  }

+

+}

diff --git a/dev/core/src/com/google/gwt/dev/javac/impl/Shared.java b/dev/core/src/com/google/gwt/dev/javac/impl/Shared.java
index 3cf1613..5c8b1c7 100644
--- a/dev/core/src/com/google/gwt/dev/javac/impl/Shared.java
+++ b/dev/core/src/com/google/gwt/dev/javac/impl/Shared.java
@@ -22,6 +22,7 @@
 import com.google.gwt.core.ext.typeinfo.JPackage;
 import com.google.gwt.core.ext.typeinfo.JParameter;
 import com.google.gwt.core.ext.typeinfo.JType;
+import com.google.gwt.dev.resource.Resource;
 import com.google.gwt.dev.util.Util;
 import com.google.gwt.util.tools.Utility;
 
@@ -109,6 +110,13 @@
     return (pos < 0) ? qualifiedTypeName : qualifiedTypeName.substring(pos + 1);
   }
 
+  public static String getTypeName(Resource sourceFile) {
+    String path = sourceFile.getPath();
+    assert (path.endsWith(".java"));
+    path = path.substring(0, path.lastIndexOf('.'));
+    return path.replace('/', '.');
+  }
+
   public static String makeTypeName(String packageName, String shortName) {
     if (packageName.length() == 0) {
       return shortName;
@@ -132,6 +140,11 @@
     }
   }
 
+  public static String readSource(Resource sourceFile) {
+    InputStream contents = sourceFile.openContents();
+    return Util.readStreamAsString(contents);
+  }
+
   public static String toPath(String qualifiedTypeName) {
     return qualifiedTypeName.replace('.', '/') + ".java";
   }
diff --git a/dev/core/src/com/google/gwt/dev/javac/impl/SourceFileCompilationUnit.java b/dev/core/src/com/google/gwt/dev/javac/impl/SourceFileCompilationUnit.java
index 6d68253..fb50b45 100644
--- a/dev/core/src/com/google/gwt/dev/javac/impl/SourceFileCompilationUnit.java
+++ b/dev/core/src/com/google/gwt/dev/javac/impl/SourceFileCompilationUnit.java
@@ -17,27 +17,13 @@
 
 import com.google.gwt.dev.javac.CompilationUnit;
 import com.google.gwt.dev.resource.Resource;
-import com.google.gwt.dev.util.Util;
 
-import java.io.InputStream;
 
 /**
  * A compilation unit that was generated.
  */
 public class SourceFileCompilationUnit extends CompilationUnit {
 
-  public static String getTypeName(Resource sourceFile) {
-    String path = sourceFile.getPath();
-    assert (path.endsWith(".java"));
-    path = path.substring(0, path.lastIndexOf('.'));
-    return path.replace('/', '.');
-  }
-
-  public static String readSource(Resource sourceFile) {
-    InputStream contents = sourceFile.openContents();
-    return Util.readStreamAsString(contents);
-  }
-
   /**
    * A token to retrieve this object's bytes from the disk cache. It's generally
    * much faster to read from the disk cache than to reread individual
@@ -64,7 +50,7 @@
   @Override
   public String getSource() {
     if (cacheToken < 0) {
-      String sourceCode = readSource(sourceFile);
+      String sourceCode = Shared.readSource(sourceFile);
       cacheToken = diskCache.writeString(sourceCode);
       return sourceCode;
     } else {
@@ -78,7 +64,7 @@
 
   @Override
   public String getTypeName() {
-    return getTypeName(sourceFile);
+    return Shared.getTypeName(sourceFile);
   }
 
   @Override
diff --git a/dev/core/test/com/google/gwt/dev/javac/CheckerTestCase.java b/dev/core/test/com/google/gwt/dev/javac/CheckerTestCase.java
index 7b24037..35db317 100644
--- a/dev/core/test/com/google/gwt/dev/javac/CheckerTestCase.java
+++ b/dev/core/test/com/google/gwt/dev/javac/CheckerTestCase.java
@@ -18,6 +18,8 @@
 import com.google.gwt.core.ext.TreeLogger;
 import com.google.gwt.core.ext.TreeLogger.Type;
 import com.google.gwt.core.ext.typeinfo.TypeOracle;
+import com.google.gwt.dev.javac.impl.StaticJavaResource;
+import com.google.gwt.dev.resource.Resource;
 import com.google.gwt.dev.util.UnitTestTreeLogger;
 
 import junit.framework.TestCase;
@@ -85,24 +87,28 @@
     shouldGenerateWarning(buggyCode, null, line, message);
   }
 
-  private void addLongCheckingCups(Set<CompilationUnit> units) {
+  private void addLongCheckingCups(Set<Resource> resources) {
     StringBuilder code = new StringBuilder();
     code.append("package com.google.gwt.core.client;\n");
     code.append("public @interface UnsafeNativeLong {\n");
     code.append("}\n");
-    units.add(new MockCompilationUnit(
+    resources.add(new StaticJavaResource(
         "com.google.gwt.core.client.UnsafeNativeLong", code.toString()));
   }
 
   private TypeOracle buildOracle(CharSequence buggyCode,
       CharSequence extraCode, UnitTestTreeLogger logger) {
-    Set<CompilationUnit> units = new HashSet<CompilationUnit>();
-    addLongCheckingCups(units);
-    units.add(new MockCompilationUnit("Buggy", buggyCode.toString()));
+    Set<Resource> resources = new HashSet<Resource>();
+    addLongCheckingCups(resources);
+    StaticJavaResource buggyResource = new StaticJavaResource("Buggy",
+        buggyCode);
+    Set<GeneratedUnit> generatedUnits = CompilationStateTestBase.getGeneratedUnits(buggyResource);
     if (extraCode != null) {
-      units.add(new MockCompilationUnit("Extra", extraCode.toString()));
+      StaticJavaResource extraResource = new StaticJavaResource("Extra",
+          extraCode);
+      generatedUnits.addAll(CompilationStateTestBase.getGeneratedUnits(extraResource));
     }
     return TypeOracleTestingUtils.buildStandardTypeOracleWith(logger,
-        units.toArray(new CompilationUnit[units.size()]));
+        resources, generatedUnits);
   }
 }
diff --git a/dev/core/test/com/google/gwt/dev/javac/CompilationStateTest.java b/dev/core/test/com/google/gwt/dev/javac/CompilationStateTest.java
index abdcfe0..91edf58 100644
--- a/dev/core/test/com/google/gwt/dev/javac/CompilationStateTest.java
+++ b/dev/core/test/com/google/gwt/dev/javac/CompilationStateTest.java
@@ -19,9 +19,11 @@
 import com.google.gwt.dev.javac.impl.JavaResourceBase;
 import com.google.gwt.dev.javac.impl.MockJavaResource;
 import com.google.gwt.dev.javac.impl.MockResourceOracle;
-import com.google.gwt.dev.javac.impl.SourceFileCompilationUnit;
+import com.google.gwt.dev.javac.impl.Shared;
+import com.google.gwt.dev.javac.impl.TweakedMockJavaResource;
 
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
@@ -36,10 +38,9 @@
 
     // Add a unit and ensure it shows up.
     addGeneratedUnits(JavaResourceBase.FOO);
-    validateCompilationState(SourceFileCompilationUnit.getTypeName(JavaResourceBase.FOO));
+    validateCompilationState(Shared.getTypeName(JavaResourceBase.FOO));
 
-    // Ensure it disappears after a refresh.
-    state.refresh(createTreeLogger());
+    rebuildCompilationState();
     validateCompilationState();
   }
 
@@ -55,10 +56,10 @@
 
   public void testCompileError() {
     oracle.add(JavaResourceBase.BAR);
-    state.refresh(createTreeLogger());
+    rebuildCompilationState();
 
     CompilationUnit badUnit = state.getCompilationUnitMap().get(
-        SourceFileCompilationUnit.getTypeName(JavaResourceBase.BAR));
+        Shared.getTypeName(JavaResourceBase.BAR));
     assertSame(State.ERROR, badUnit.getState());
 
     Set<CompilationUnit> goodUnits = new HashSet<CompilationUnit>(
@@ -78,7 +79,7 @@
     addGeneratedUnits(JavaResourceBase.BAR);
 
     CompilationUnit badUnit = state.getCompilationUnitMap().get(
-        SourceFileCompilationUnit.getTypeName(JavaResourceBase.BAR));
+        Shared.getTypeName(JavaResourceBase.BAR));
     assertSame(State.ERROR, badUnit.getState());
 
     Set<CompilationUnit> goodUnits = new HashSet<CompilationUnit>(
@@ -90,22 +91,23 @@
   public void testCompileWithGeneratedUnitsErrorAndDepedentGeneratedUnit() {
     assertUnitsChecked(state.getCompilationUnits());
     MockJavaResource badFoo = new MockJavaResource(
-        SourceFileCompilationUnit.getTypeName(JavaResourceBase.FOO)) {
+        Shared.getTypeName(JavaResourceBase.FOO)) {
       @Override
       protected CharSequence getContent() {
-        return SourceFileCompilationUnit.readSource(JavaResourceBase.FOO)
+        return Shared.readSource(JavaResourceBase.FOO)
             + "\ncompilation error LOL!";
       }
     };
-    state.addGeneratedCompilationUnits(createTreeLogger(), getCompilationUnits(
-        badFoo, JavaResourceBase.BAR));
+    oracle.add(badFoo);
+    rebuildCompilationState();
+    addGeneratedUnits(JavaResourceBase.BAR);
 
     CompilationUnit badUnit = state.getCompilationUnitMap().get(
-        SourceFileCompilationUnit.getTypeName(badFoo));
+        Shared.getTypeName(badFoo));
     assertSame(State.ERROR, badUnit.getState());
     CompilationUnit invalidUnit = state.getCompilationUnitMap().get(
-        SourceFileCompilationUnit.getTypeName(JavaResourceBase.BAR));
-    assertSame(State.FRESH, invalidUnit.getState());
+        Shared.getTypeName(JavaResourceBase.BAR));
+    assertSame(State.ERROR, invalidUnit.getState());
 
     Set<CompilationUnit> goodUnits = new HashSet<CompilationUnit>(
         state.getCompilationUnits());
@@ -119,12 +121,13 @@
    * another generated unit it depends on can be reused
    */
   public void testComplexCacheInvalidation() {
-    Set<CompilationUnit> modifiedUnits = getCompilationUnits(JavaResourceBase.FOO);
-    modifiedUnits.addAll(getModifiedCompilationUnits(JavaResourceBase.BAR));
-    Set<String> reusedTypes = new HashSet<String>();
-    reusedTypes.add(SourceFileCompilationUnit.getTypeName(JavaResourceBase.FOO));
-    testCachingOverMultipleRefreshes(getCompilationUnits(JavaResourceBase.FOO,
-        JavaResourceBase.BAR), modifiedUnits, reusedTypes, 1);
+    testCachingOverMultipleRefreshes(new MockJavaResource[] {
+        JavaResourceBase.FOO, JavaResourceBase.BAR},
+        new MockJavaResource[] {
+            JavaResourceBase.FOO,
+            new TweakedMockJavaResource(JavaResourceBase.BAR)},
+        Collections.singleton(JavaResourceBase.FOO.getTypeName()));
+
   }
 
   public void testInitialization() {
@@ -132,55 +135,51 @@
   }
 
   public void testInvalidation() {
-    testCachingOverMultipleRefreshes(getCompilationUnits(JavaResourceBase.FOO),
-        getModifiedCompilationUnits(JavaResourceBase.FOO),
-        Collections.<String> emptySet(), 1);
+    testCachingOverMultipleRefreshes(
+        new MockJavaResource[] {JavaResourceBase.FOO},
+        new MockJavaResource[] {new TweakedMockJavaResource(
+            JavaResourceBase.FOO)}, Collections.<String> emptySet());
   }
 
   public void testInvalidationOfMultipleUnits() {
-    testCachingOverMultipleRefreshes(getCompilationUnits(JavaResourceBase.BAR,
-        JavaResourceBase.FOO), getModifiedCompilationUnits(
-        JavaResourceBase.BAR, JavaResourceBase.FOO),
-        Collections.<String> emptySet(), 2);
+    testCachingOverMultipleRefreshes(new MockJavaResource[] {
+        JavaResourceBase.FOO, JavaResourceBase.BAR}, new MockJavaResource[] {
+        new TweakedMockJavaResource(JavaResourceBase.FOO),
+        new TweakedMockJavaResource(JavaResourceBase.BAR)},
+        Collections.<String> emptySet());
   }
 
-  /*
-   * Steps: (i) Check compilation state. (ii) Add generated units. (iii) Change
-   * unit in source oracle. (iv) Refresh oracle. (v) Add same generated units.
-   * (v) Check that there is no reuse.
-   */
   public void testInvalidationWhenSourceUnitsChange() {
+    /*
+     * Steps: (i) Check compilation state. (ii) Add generated units. (iii)
+     * Change unit in source oracle. (iv) Refresh oracle. (v) Add same generated
+     * units. (v) Check that there is no reuse.
+     */
     validateCompilationState();
     oracle.add(JavaResourceBase.FOO);
-    state.refresh(createTreeLogger());
+    rebuildCompilationState();
 
     // add generated units
-    Set<CompilationUnit> generatedCups = getCompilationUnits(JavaResourceBase.BAR);
-    Map<String, CompilationUnit> usefulUnits = state.getUsefulGraveyardUnits(generatedCups);
-    assertEquals(0, usefulUnits.size());
-    state.addGeneratedCompilationUnits(createTreeLogger(), generatedCups,
-        usefulUnits);
+    addGeneratedUnits(JavaResourceBase.BAR);
     assertUnitsChecked(state.getCompilationUnits());
+    CompilationUnit oldBar = state.getCompilationUnitMap().get(
+        JavaResourceBase.BAR.getTypeName());
+    assertNotNull(oldBar);
 
     // change unit in source oracle
-    oracle.replace(new MockJavaResource(
-        SourceFileCompilationUnit.getTypeName(JavaResourceBase.FOO)) {
-      @Override
-      protected CharSequence getContent() {
-        return SourceFileCompilationUnit.readSource(JavaResourceBase.FOO)
-            + "\n";
-      }
-    });
-    state.refresh(createTreeLogger());
+    oracle.replace(new TweakedMockJavaResource(JavaResourceBase.FOO));
+    rebuildCompilationState();
 
     /*
-     * Add same generated units. Verify that the generated units are not used.
+     * Add same generated units. Verify that the original units are not used.
      */
-    usefulUnits = state.getUsefulGraveyardUnits(generatedCups);
-    assertEquals(0, usefulUnits.size());
-    state.addGeneratedCompilationUnits(createTreeLogger(), generatedCups,
-        usefulUnits);
+    addGeneratedUnits(JavaResourceBase.BAR);
     assertUnitsChecked(state.getCompilationUnits());
+
+    CompilationUnit newBar = state.getCompilationUnitMap().get(
+        JavaResourceBase.BAR.getTypeName());
+    assertNotNull(newBar);
+    assertNotSame(oldBar, newBar);
   }
 
   public void testSourceOracleAdd() {
@@ -188,7 +187,7 @@
 
     int size = state.getCompilationUnits().size();
     oracle.add(JavaResourceBase.FOO);
-    state.refresh(createTreeLogger());
+    rebuildCompilationState();
     assertEquals(size + 1, state.getCompilationUnits().size());
     validateCompilationState();
   }
@@ -208,7 +207,7 @@
 
     int size = state.getCompilationUnits().size();
     oracle.remove(JavaResourceBase.OBJECT.getPath());
-    state.refresh(createTreeLogger());
+    rebuildCompilationState();
     assertEquals(size - 1, state.getCompilationUnits().size());
     validateCompilationState();
   }
@@ -217,13 +216,8 @@
     validateCompilationState();
 
     int size = state.getCompilationUnits().size();
-    oracle.replace(new MockJavaResource("java.lang.Object") {
-      @Override
-      protected CharSequence getContent() {
-        return SourceFileCompilationUnit.readSource(JavaResourceBase.OBJECT);
-      }
-    });
-    state.refresh(createTreeLogger());
+    oracle.replace(new TweakedMockJavaResource(JavaResourceBase.OBJECT));
+    rebuildCompilationState();
     assertEquals(size, state.getCompilationUnits().size());
     validateCompilationState();
   }
@@ -233,27 +227,26 @@
 
     int size = state.getCompilationUnits().size();
     oracle.replace(JavaResourceBase.OBJECT);
-    state.refresh(createTreeLogger());
+    rebuildCompilationState();
     assertEquals(size, state.getCompilationUnits().size());
     validateCompilationState();
   }
 
   /* test if generatedUnits that depend on stale generatedUnits are invalidated */
   public void testTransitiveInvalidation() {
-    Set<CompilationUnit> modifiedUnits = getModifiedCompilationUnits(JavaResourceBase.FOO);
-    modifiedUnits.addAll(getCompilationUnits(JavaResourceBase.BAR));
-    testCachingOverMultipleRefreshes(getCompilationUnits(JavaResourceBase.BAR,
-        JavaResourceBase.FOO), modifiedUnits, Collections.<String> emptySet(),
-        2);
+    testCachingOverMultipleRefreshes(new MockJavaResource[] {
+        JavaResourceBase.FOO, JavaResourceBase.BAR},
+        new MockJavaResource[] {
+            new TweakedMockJavaResource(JavaResourceBase.FOO),
+            JavaResourceBase.BAR}, Collections.<String> emptySet());
   }
 
-  private void testCaching(MockJavaResource... files) {
+  private void testCaching(MockJavaResource... resources) {
     Set<String> reusedTypes = new HashSet<String>();
-    for (MockJavaResource file : files) {
-      reusedTypes.add(SourceFileCompilationUnit.getTypeName(file));
+    for (MockJavaResource resource : resources) {
+      reusedTypes.add(resource.getTypeName());
     }
-    testCachingOverMultipleRefreshes(getCompilationUnits(files),
-        getCompilationUnits(files), reusedTypes, 0);
+    testCachingOverMultipleRefreshes(resources, resources, reusedTypes);
   }
 
   /**
@@ -271,64 +264,56 @@
    *          initialSet and updatedSet.
    * @param numInvalidated Number of types invalidated from graveyardUnits.
    */
-  private void testCachingOverMultipleRefreshes(
-      Set<CompilationUnit> initialSet, Set<CompilationUnit> updatedSet,
-      Set<String> reusedTypes, int numInvalidated) {
+  private void testCachingOverMultipleRefreshes(MockJavaResource[] initialSet,
+      MockJavaResource[] updatedSet, Set<String> reusedTypes) {
 
-    // verify that there were no generated units before.
-    state.refresh(createTreeLogger());
-    assertEquals(0, state.graveyardUnits.size());
+    // Add 'initialSet' generatedUnits on the first cycle.
+    rebuildCompilationState();
+    assertEquals(oracle.getResources().size(),
+        state.getCompilationUnits().size());
+    addGeneratedUnits(initialSet);
+    Map<String, CompilationUnit> units1 = new HashMap<String, CompilationUnit>(
+        state.getCompilationUnitMap());
+    assertEquals(oracle.getResources().size() + initialSet.length,
+        units1.size());
+    assertUnitsChecked(units1.values());
 
-    // add 'initialSet' generatedUnits over the first refresh cycle.
-    testCachingOverSingleRefresh(new HashSet<CompilationUnit>(initialSet), 0,
-        Collections.<String> emptySet(), 0);
+    // Add 'updatedSet' generatedUnits on the second cycle.
+    rebuildCompilationState();
+    assertEquals(oracle.getResources().size(),
+        state.getCompilationUnits().size());
+    addGeneratedUnits(updatedSet);
+    Map<String, CompilationUnit> units2 = new HashMap<String, CompilationUnit>(
+        state.getCompilationUnitMap());
+    assertEquals(oracle.getResources().size() + updatedSet.length,
+        units2.size());
+    assertUnitsChecked(units2.values());
 
-    // add 'updatedSet' generatedUnits over the second refresh cycle.
-    testCachingOverSingleRefresh(new HashSet<CompilationUnit>(updatedSet),
-        initialSet.size(), reusedTypes, numInvalidated);
-
-    // add 'updatedSet' generatedUnits over the third refresh cycle.
-    reusedTypes = new HashSet<String>();
-    for (CompilationUnit unit : updatedSet) {
-      reusedTypes.add(unit.getTypeName());
+    // Validate that only 'reusedTypes' are reused.
+    for (MockJavaResource resource : updatedSet) {
+      String typeName = resource.getTypeName();
+      if (reusedTypes.contains(typeName)) {
+        assertSame(units1.get(typeName), units2.get(typeName));
+      } else {
+        assertNotSame(units1.get(typeName), units2.get(typeName));
+      }
     }
-    testCachingOverSingleRefresh(new HashSet<CompilationUnit>(updatedSet),
-        updatedSet.size(), reusedTypes, 0);
-  }
 
-  /**
-   * Steps:
-   * <ol>
-   * <li>Check graveyardUnits before refresh. assert size is 0.</li>
-   * <li>Refresh. assert size is 'graveyardUnitsSize'.</li>
-   * <li>Add generated cups. Confirm that the 'reusedTypes' and 'numInvalidated'
-   * match.</li>
-   * </ol>
-   * 
-   * @param generatedCups generated CompilationUnits to be added.
-   * @param graveyardUnitsSize initial expected size of graveyard units.
-   * @param reusedTypes Main type of the units that can be reused between the
-   *          initialSet and updatedSet.
-   * @param numInvalidated Number of types invalidated from graveyardUnits.
-   */
-  private void testCachingOverSingleRefresh(Set<CompilationUnit> generatedCups,
-      int graveyardUnitsSize, Set<String> reusedTypes, int numInvalidated) {
-    assertEquals(0, state.graveyardUnits.size());
+    // Add 'updatedSet' generatedUnits on the third cycle.
+    rebuildCompilationState();
+    assertEquals(oracle.getResources().size(),
+        state.getCompilationUnits().size());
+    addGeneratedUnits(updatedSet);
+    Map<String, CompilationUnit> units3 = new HashMap<String, CompilationUnit>(
+        state.getCompilationUnitMap());
+    assertEquals(oracle.getResources().size() + updatedSet.length,
+        units3.size());
+    assertUnitsChecked(units3.values());
 
-    assertUnitsChecked(state.getCompilationUnits());
-    state.refresh(createTreeLogger());
-    assertEquals(graveyardUnitsSize, state.graveyardUnits.size());
-
-    int initialSize = state.graveyardUnits.size();
-    Map<String, CompilationUnit> usefulUnits = state.getUsefulGraveyardUnits(generatedCups);
-    assertEquals(reusedTypes.size(), usefulUnits.size());
-    for (String typeName : reusedTypes) {
-      assertNotNull(usefulUnits.get(typeName));
+    // Validate that all generatedUnits are reused.
+    for (MockJavaResource resource : updatedSet) {
+      String typeName = resource.getTypeName();
+      assertSame(units2.get(typeName), units3.get(typeName));
     }
-    assertEquals(numInvalidated, initialSize - reusedTypes.size()
-        - state.graveyardUnits.size());
-    state.addGeneratedCompilationUnits(createTreeLogger(), generatedCups,
-        usefulUnits);
-    assertUnitsChecked(state.getCompilationUnits());
   }
 }
diff --git a/dev/core/test/com/google/gwt/dev/javac/CompilationStateTestBase.java b/dev/core/test/com/google/gwt/dev/javac/CompilationStateTestBase.java
index 4de3599..79fb630 100644
--- a/dev/core/test/com/google/gwt/dev/javac/CompilationStateTestBase.java
+++ b/dev/core/test/com/google/gwt/dev/javac/CompilationStateTestBase.java
@@ -20,8 +20,9 @@
 import com.google.gwt.dev.javac.StandardGeneratorContext.Generated;

 import com.google.gwt.dev.javac.impl.JavaResourceBase;

 import com.google.gwt.dev.javac.impl.MockJavaResource;

+import com.google.gwt.dev.javac.impl.MockResource;

 import com.google.gwt.dev.javac.impl.MockResourceOracle;

-import com.google.gwt.dev.javac.impl.SourceFileCompilationUnit;

+import com.google.gwt.dev.javac.impl.Shared;

 import com.google.gwt.dev.resource.Resource;

 import com.google.gwt.dev.util.Util;

 import com.google.gwt.dev.util.log.AbstractTreeLogger;

@@ -43,15 +44,13 @@
  */

 public abstract class CompilationStateTestBase extends TestCase {

 

-  protected static class GeneratedSourceFileCompilationUnit extends

-      SourceFileCompilationUnit implements Generated {

+  public static class GeneratedSourceFileCompilationUnit extends

+      CompilationUnit implements Generated {

 

-    private final boolean modifySource;

-    private String strongHash;

+    private final GeneratedUnit generatedUnit;

 

-    public GeneratedSourceFileCompilationUnit(Resource sourceFile, boolean modifySource) {

-      super(sourceFile);

-      this.modifySource = modifySource;

+    public GeneratedSourceFileCompilationUnit(GeneratedUnit generatedUnit) {

+      this.generatedUnit = generatedUnit;

     }

 

     public void abort() {

@@ -61,39 +60,44 @@
     }

 

     @Override

+    public String getDisplayLocation() {

+      return generatedUnit.optionalFileLocation();

+    }

+

+    @Override

+    public long getLastModified() {

+      return generatedUnit.creationTime();

+    }

+

+    @Override

     public String getSource() {

-      String extraChars = "";

-      if (modifySource) {

-        extraChars = "\n";

-      }

-      return super.getSource() + extraChars;

+      return generatedUnit.getSource();

     }

 

     public String getStrongHash() {

-      if (strongHash == null) {

-        strongHash = Util.computeStrongName(Util.getBytes(getSource()));

-      }

-      return strongHash;

+      return generatedUnit.getStrongHash();

+    }

+

+    @Override

+    public String getTypeName() {

+      return generatedUnit.getTypeName();

     }

 

     @Override

     public boolean isGenerated() {

       return true;

     }

-  }

 

-  static void assertUnitsChecked(Collection<CompilationUnit> units) {

-    for (CompilationUnit unit : units) {

-      assertSame(State.CHECKED, unit.getState());

-      assertNull(unit.getErrors());

-      assertTrue(unit.getCompiledClasses().size() > 0);

+    @Override

+    public boolean isSuperSource() {

+      return false;

     }

   }

 

   /**

    * Tweak this if you want to see the log output.

    */

-  protected static TreeLogger createTreeLogger() {

+  public static TreeLogger createTreeLogger() {

     boolean reallyLog = false;

     if (reallyLog) {

       AbstractTreeLogger logger = new PrintWriterTreeLogger();

@@ -103,6 +107,43 @@
     return TreeLogger.NULL;

   }

 

+  public static Set<GeneratedUnit> getGeneratedUnits(

+      MockResource... sourceFiles) {

+    Set<GeneratedUnit> units = new HashSet<GeneratedUnit>();

+    for (final MockResource sourceFile : sourceFiles) {

+      units.add(new GeneratedUnit() {

+        public long creationTime() {

+          return sourceFile.getLastModified();

+        }

+

+        public String getSource() {

+          return sourceFile.getString();

+        }

+

+        public String getStrongHash() {

+          return Util.computeStrongName(Util.getBytes(getSource()));

+        }

+

+        public String getTypeName() {

+          return Shared.getTypeName(sourceFile);

+        }

+

+        public String optionalFileLocation() {

+          return sourceFile.getLocation();

+        }

+      });

+    }

+    return units;

+  }

+

+  static void assertUnitsChecked(Collection<CompilationUnit> units) {

+    for (CompilationUnit unit : units) {

+      assertSame(State.CHECKED, unit.getState());

+      assertFalse(unit.isError());

+      assertTrue(unit.getCompiledClasses().size() > 0);

+    }

+  }

+

   protected MockResourceOracle oracle = new MockResourceOracle(

       JavaResourceBase.getStandardResources());

 

@@ -110,28 +151,16 @@
       oracle);

 

   protected void addGeneratedUnits(MockJavaResource... sourceFiles) {

-    Set<CompilationUnit> units = getCompilationUnits(sourceFiles);

+    Set<CompilationUnit> units = new HashSet<CompilationUnit>();

+    Set<GeneratedUnit> generatedUnits = getGeneratedUnits(sourceFiles);

+    for (GeneratedUnit generatedUnit : generatedUnits) {

+      units.add(new GeneratedSourceFileCompilationUnit(generatedUnit));

+    }

     state.addGeneratedCompilationUnits(createTreeLogger(), units);

   }

 

-  protected Set<CompilationUnit> getCompilationUnits(

-      MockJavaResource... sourceFiles) {

-    Set<CompilationUnit> units = new HashSet<CompilationUnit>();

-    for (MockJavaResource sourceFile : sourceFiles) {

-      // keep the same source

-      units.add(new GeneratedSourceFileCompilationUnit(sourceFile, false));

-    }

-    return units;

-  }

-

-  protected Set<CompilationUnit> getModifiedCompilationUnits(

-      MockJavaResource... sourceFiles) {

-    Set<CompilationUnit> units = new HashSet<CompilationUnit>();

-    for (MockJavaResource sourceFile : sourceFiles) {

-      // modify the source

-      units.add(new GeneratedSourceFileCompilationUnit(sourceFile, true));

-    }

-    return units;

+  protected void rebuildCompilationState() {

+    state.refresh(createTreeLogger());

   }

 

   protected void validateCompilationState(String... generatedTypeNames) {

@@ -156,8 +185,10 @@
       assertEquals(className, unit.getTypeName());

 

       // Find the matching resource (and remove it).

-      if (unit.isGenerated()) {

-        assertTrue(generatedTypes.contains(className));

+      if (generatedTypes.contains(className)) {

+        // Not always true due to caching! A source unit for FOO can b

+        // identical to the generated FOO and already be cached.

+        // assertTrue(unit.isGenerated());

         assertNotNull(generatedTypes.remove(className));

       } else {

         String partialPath = className.replace('.', '/') + ".java";

diff --git a/dev/core/test/com/google/gwt/dev/javac/CompilationUnitFileReferenceTest.java b/dev/core/test/com/google/gwt/dev/javac/CompilationUnitFileReferenceTest.java
index 6748ae3..7884031 100644
--- a/dev/core/test/com/google/gwt/dev/javac/CompilationUnitFileReferenceTest.java
+++ b/dev/core/test/com/google/gwt/dev/javac/CompilationUnitFileReferenceTest.java
@@ -15,16 +15,9 @@
  */
 package com.google.gwt.dev.javac;
 
-import com.google.gwt.core.ext.TreeLogger;
 import com.google.gwt.dev.javac.impl.JavaResourceBase;
 import com.google.gwt.dev.javac.impl.MockJavaResource;
-import com.google.gwt.dev.javac.impl.MockResourceOracle;
-import com.google.gwt.dev.javac.impl.SourceFileCompilationUnit;
 import com.google.gwt.dev.resource.Resource;
-import com.google.gwt.dev.util.log.AbstractTreeLogger;
-import com.google.gwt.dev.util.log.PrintWriterTreeLogger;
-
-import junit.framework.TestCase;
 
 import java.util.HashMap;
 import java.util.HashSet;
@@ -34,7 +27,7 @@
 /**
  * Test if all fileReferences in a compilationUnit are recorded correctly.
  */
-public class CompilationUnitFileReferenceTest extends TestCase {
+public class CompilationUnitFileReferenceTest extends CompilationStateTestBase {
 
   public static final MockJavaResource MEMBER_INNER_SUBCLASS = new MockJavaResource(
       "test.OuterSubclass") {
@@ -137,34 +130,15 @@
         JavaResourceBase.STRING, OUTER);
   }
 
-  /**
-   * Tweak this if you want to see the log output.
-   */
-  private static TreeLogger createTreeLogger() {
-    boolean reallyLog = false;
-    if (reallyLog) {
-      AbstractTreeLogger logger = new PrintWriterTreeLogger();
-      logger.setMaxDetail(TreeLogger.ALL);
-      return logger;
-    }
-    return TreeLogger.NULL;
-  }
-
-  private static void initializeExpectedDependency(Resource source,
-      Resource... targets) {
+  private static void initializeExpectedDependency(MockJavaResource source,
+      MockJavaResource... targets) {
     Set<String> targetSet = new HashSet<String>();
-    for (Resource target : targets) {
-      targetSet.add(target.getLocation());
+    for (MockJavaResource target : targets) {
+      targetSet.add(target.getTypeName());
     }
-    EXPECTED_DEPENDENCIES.put(source.getLocation(), targetSet);
+    EXPECTED_DEPENDENCIES.put(source.getTypeName(), targetSet);
   }
 
-  private MockResourceOracle oracle = new MockResourceOracle(
-      JavaResourceBase.getStandardResources());
-
-  private CompilationState state = new CompilationState(createTreeLogger(),
-      oracle);
-
   public void testBinaryBindingsWithMemberInnerClass() {
     testBinaryBindings(OUTER, MEMBER_INNER_SUBCLASS);
   }
@@ -198,54 +172,41 @@
   }
 
   public void testWithGeneratedUnits() {
-    state.addGeneratedCompilationUnits(createTreeLogger(),
-        copyAsGeneratedUnits(JavaResourceBase.BAR, JavaResourceBase.FOO));
-    assertRefsMatchExpectedRefs(JavaResourceBase.BAR, JavaResourceBase.FOO);
+    addGeneratedUnits(JavaResourceBase.FOO, JavaResourceBase.BAR);
+    assertRefsMatchExpectedRefs(JavaResourceBase.FOO, JavaResourceBase.BAR);
   }
 
   public void testWithMixedUnits() {
     oracle.add(JavaResourceBase.FOO);
-    state.refresh(createTreeLogger());
-    state.addGeneratedCompilationUnits(createTreeLogger(),
-        copyAsGeneratedUnits(JavaResourceBase.BAR));
-    assertRefsMatchExpectedRefs(JavaResourceBase.BAR, JavaResourceBase.FOO);
+    rebuildCompilationState();
+    addGeneratedUnits(JavaResourceBase.BAR);
+    assertRefsMatchExpectedRefs(JavaResourceBase.FOO, JavaResourceBase.BAR);
   }
 
-  private void assertRefsMatchExpectedRefs(Resource... files) {
-    for (Resource sourceFile : files) {
-      Set<String> sourceFileRefs = state.getCompilationUnitMap().get(
-          SourceFileCompilationUnit.getTypeName(sourceFile)).getFileNameRefs();
-      Set<String> expectedSourceFileRefs = EXPECTED_DEPENDENCIES.get(sourceFile.getLocation());
-      assertEquals(expectedSourceFileRefs, sourceFileRefs);
+  private void assertRefsMatchExpectedRefs(MockJavaResource... files) {
+    Map<String, CompilationUnit> unitMap = state.getCompilationUnitMap();
+    for (MockJavaResource file : files) {
+      String typeName = file.getTypeName();
+      Set<String> sourceFileRefs = unitMap.get(typeName).getFileNameRefs();
+      Set<String> expectedTypeNames = EXPECTED_DEPENDENCIES.get(typeName);
+      assertEquals(expectedTypeNames.size(), sourceFileRefs.size());
+      for (String expectedTypeName : expectedTypeNames) {
+        CompilationUnit expectedUnit = unitMap.get(expectedTypeName);
+        assertNotNull(expectedUnit);
+        assertTrue(sourceFileRefs.contains(expectedUnit.getDisplayLocation()));
+      }
     }
   }
 
   /**
-   * Returns copies of units as generated units for testing interactions with
-   * generated units.
-   */
-  private Set<CompilationUnit> copyAsGeneratedUnits(Resource... sourceFiles) {
-    Set<CompilationUnit> units = new HashSet<CompilationUnit>();
-    for (Resource sourceFile : sourceFiles) {
-      units.add(new SourceFileCompilationUnit(sourceFile) {
-        @Override
-        public boolean isGenerated() {
-          return true;
-        }
-      });
-    }
-    return units;
-  }
-
-  /**
    * Independently compiles each file in order to force each subsequent unit to
    * have only binary references to the previous unit(s). This tests the binary
    * reference matching in {@link CompilationState}.
    */
-  private void testBinaryBindings(Resource... files) {
+  private void testBinaryBindings(MockJavaResource... files) {
     for (Resource sourceFile : files) {
       oracle.add(sourceFile);
-      state.refresh(createTreeLogger());
+      rebuildCompilationState();
     }
     assertRefsMatchExpectedRefs(files);
   }
@@ -255,11 +216,11 @@
    * to each other. This tests the source reference matching in
    * {@link CompilationState}.
    */
-  private void testSourceBindings(Resource... files) {
+  private void testSourceBindings(MockJavaResource... files) {
     for (Resource sourceFile : files) {
       oracle.add(sourceFile);
     }
-    state.refresh(createTreeLogger());
+    rebuildCompilationState();
     assertRefsMatchExpectedRefs(files);
   }
 }
diff --git a/dev/core/test/com/google/gwt/dev/javac/JSORestrictionsTest.java b/dev/core/test/com/google/gwt/dev/javac/JSORestrictionsTest.java
index 435a509..c97b513 100644
--- a/dev/core/test/com/google/gwt/dev/javac/JSORestrictionsTest.java
+++ b/dev/core/test/com/google/gwt/dev/javac/JSORestrictionsTest.java
@@ -16,10 +16,14 @@
 package com.google.gwt.dev.javac;
 
 import com.google.gwt.core.ext.TreeLogger;
+import com.google.gwt.dev.javac.impl.StaticJavaResource;
+import com.google.gwt.dev.resource.Resource;
 import com.google.gwt.dev.util.UnitTestTreeLogger;
 
 import junit.framework.TestCase;
 
+import java.util.Collections;
+
 /**
  * Tests the JSORestrictionsChecker.
  */
@@ -290,9 +294,11 @@
       }
     }
     UnitTestTreeLogger logger = builder.createLogger();
-    CompilationUnit buggyCup = new MockCompilationUnit("Buggy",
-        buggyCode.toString());
-    TypeOracleTestingUtils.buildStandardTypeOracleWith(logger, buggyCup);
+    StaticJavaResource buggyResource = new StaticJavaResource("Buggy",
+        buggyCode);
+    TypeOracleTestingUtils.buildStandardTypeOracleWith(logger,
+        Collections.<Resource> emptySet(),
+        CompilationStateTestBase.getGeneratedUnits(buggyResource));
     logger.assertCorrectLogEntries();
   }
 
diff --git a/dev/core/test/com/google/gwt/dev/javac/MockCompilationUnit.java b/dev/core/test/com/google/gwt/dev/javac/MockCompilationUnit.java
deleted file mode 100644
index d12e577..0000000
--- a/dev/core/test/com/google/gwt/dev/javac/MockCompilationUnit.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright 2008 Google Inc.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.gwt.dev.javac;
-
-import com.google.gwt.dev.util.Name.BinaryName;
-
-public class MockCompilationUnit extends CompilationUnit {
-
-  private final String typeName;
-  private final String source;
-
-  public MockCompilationUnit(String typeName) {
-    this.typeName = typeName;
-    this.source = null;
-  }
-
-  public MockCompilationUnit(String typeName, String source) {
-    this.typeName = typeName;
-    this.source = source;
-  }
-
-  public String getDisplayLocation() {
-    return "/mock/" + BinaryName.toInternalName(typeName) + ".java";
-  }
-
-  @Override
-  public long getLastModified() {
-    return 0;
-  }
-
-  @Override
-  public String getSource() {
-    assert source != null;
-    return source;
-  }
-
-  public String getTypeName() {
-    return typeName;
-  }
-
-  public boolean isGenerated() {
-    return true;
-  }
-
-  @Override
-  public boolean isSuperSource() {
-    return false;
-  }
-}
diff --git a/dev/core/test/com/google/gwt/dev/javac/TypeOracleMediatorTest.java b/dev/core/test/com/google/gwt/dev/javac/TypeOracleMediatorTest.java
index 98377eb..32d8358 100644
--- a/dev/core/test/com/google/gwt/dev/javac/TypeOracleMediatorTest.java
+++ b/dev/core/test/com/google/gwt/dev/javac/TypeOracleMediatorTest.java
@@ -16,7 +16,6 @@
 package com.google.gwt.dev.javac;
 
 import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.core.ext.UnableToCompleteException;
 import com.google.gwt.core.ext.typeinfo.JArrayType;
 import com.google.gwt.core.ext.typeinfo.JClassType;
 import com.google.gwt.core.ext.typeinfo.JField;
@@ -26,7 +25,10 @@
 import com.google.gwt.core.ext.typeinfo.NotFoundException;
 import com.google.gwt.core.ext.typeinfo.TypeOracle;
 import com.google.gwt.core.ext.typeinfo.TypeOracleException;
+import com.google.gwt.dev.javac.impl.MockJavaResource;
 import com.google.gwt.dev.javac.impl.Shared;
+import com.google.gwt.dev.javac.impl.StaticJavaResource;
+import com.google.gwt.dev.resource.Resource;
 import com.google.gwt.dev.util.log.AbstractTreeLogger;
 import com.google.gwt.dev.util.log.PrintWriterTreeLogger;
 
@@ -35,7 +37,6 @@
 import org.apache.commons.collections.map.AbstractReferenceMap;
 import org.apache.commons.collections.map.ReferenceMap;
 
-import java.io.IOException;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
@@ -43,9 +44,35 @@
 
 public class TypeOracleMediatorTest extends TestCase {
 
-  private abstract class CheckedMockCompilationUnit extends MockCompilationUnit {
-    public CheckedMockCompilationUnit(String packageName,
-        String shortMainTypeName, String... shortTypeNames) {
+  private abstract class MutableJavaResource extends MockJavaResource {
+    private String extraSource = "";
+    private long lastModified = System.currentTimeMillis();
+
+    public MutableJavaResource(String qualifiedTypeName) {
+      super(qualifiedTypeName);
+    }
+
+    @Override
+    public long getLastModified() {
+      return lastModified;
+    }
+
+    @Override
+    protected CharSequence getContent() {
+      return getSource() + extraSource;
+    }
+
+    public abstract String getSource();
+
+    public void touch() {
+      extraSource += '\n';
+      lastModified = System.currentTimeMillis();
+    }
+  }
+
+  private abstract class CheckedJavaResource extends MutableJavaResource {
+    public CheckedJavaResource(String packageName, String shortMainTypeName,
+        String... shortTypeNames) {
       super(Shared.makeTypeName(packageName, shortMainTypeName));
       register(getTypeName(), this);
       for (String shortTypeName : shortTypeNames) {
@@ -54,9 +81,6 @@
     }
 
     public abstract void check(JClassType type) throws NotFoundException;
-
-    @Override
-    public abstract String getSource();
   }
 
   private static void assertIsAssignable(JClassType from, JClassType to) {
@@ -87,9 +111,9 @@
   /**
    * Public so that this will be initialized before the CUs.
    */
-  public final Map<String, CheckedMockCompilationUnit> publicTypeNameToTestCupMap = new HashMap<String, CheckedMockCompilationUnit>();
+  public final Map<String, CheckedJavaResource> publicTypeNameToTestCupMap = new HashMap<String, CheckedJavaResource>();
 
-  protected CheckedMockCompilationUnit CU_AfterAssimilate = new CheckedMockCompilationUnit(
+  protected CheckedJavaResource CU_AfterAssimilate = new CheckedJavaResource(
       "test.assim", "AfterAssimilate") {
     @Override
     public void check(JClassType type) {
@@ -106,7 +130,7 @@
     }
   };
 
-  protected CheckedMockCompilationUnit CU_Assignable = new CheckedMockCompilationUnit(
+  protected CheckedJavaResource CU_Assignable = new CheckedJavaResource(
       "test.sub", "Derived", "BaseInterface", "DerivedInterface",
       "Derived.Nested") {
     @Override
@@ -141,7 +165,7 @@
     }
   };
 
-  protected CheckedMockCompilationUnit CU_BeforeAssimilate = new CheckedMockCompilationUnit(
+  protected CheckedJavaResource CU_BeforeAssimilate = new CheckedJavaResource(
       "test.assim", "BeforeAssimilate") {
     @Override
     public void check(JClassType type) {
@@ -157,7 +181,7 @@
     }
   };
 
-  protected CheckedMockCompilationUnit CU_BindToTypeScope = new CheckedMockCompilationUnit(
+  protected CheckedJavaResource CU_BindToTypeScope = new CheckedJavaResource(
       "test", "BindToTypeScope", "BindToTypeScope.Object",
       "BindToTypeScope.DerivedObject") {
 
@@ -211,7 +235,7 @@
     }
   };
 
-  protected CheckedMockCompilationUnit CU_DeclaresInnerGenericType = new CheckedMockCompilationUnit(
+  protected CheckedJavaResource CU_DeclaresInnerGenericType = new CheckedJavaResource(
       "parameterized.type.build.dependency", "Class1", "Class1.Inner") {
     @Override
     public void check(JClassType type) throws NotFoundException {
@@ -229,7 +253,7 @@
     }
   };
 
-  protected CheckedMockCompilationUnit CU_DefaultClass = new CheckedMockCompilationUnit(
+  protected CheckedJavaResource CU_DefaultClass = new CheckedJavaResource(
       "test", "DefaultClass") {
     @Override
     public void check(JClassType type) {
@@ -252,7 +276,7 @@
     }
   };
 
-  protected CheckedMockCompilationUnit CU_ExtendsGenericList = new CheckedMockCompilationUnit(
+  protected CheckedJavaResource CU_ExtendsGenericList = new CheckedJavaResource(
       "test.refresh", "ExtendsGenericList") {
 
     @Override
@@ -269,7 +293,7 @@
     }
   };
 
-  protected CheckedMockCompilationUnit CU_ExtendsParameterizedType = new CheckedMockCompilationUnit(
+  protected CheckedJavaResource CU_ExtendsParameterizedType = new CheckedJavaResource(
       "parameterized.type.build.dependency", "Class2") {
     @Override
     public void check(JClassType type) throws NotFoundException {
@@ -285,7 +309,7 @@
     }
   };
 
-  protected CheckedMockCompilationUnit CU_FieldsAndTypes = new CheckedMockCompilationUnit(
+  protected CheckedJavaResource CU_FieldsAndTypes = new CheckedJavaResource(
       "test", "Fields", "SomeType") {
     @Override
     public void check(JClassType type) throws NotFoundException {
@@ -377,6 +401,7 @@
       }
     }
 
+    @Override
     public String getSource() {
       StringBuffer sb = new StringBuffer();
       sb.append("package test;\n");
@@ -399,13 +424,14 @@
     }
   };
 
-  protected CheckedMockCompilationUnit CU_GenericList = new CheckedMockCompilationUnit(
+  protected CheckedJavaResource CU_GenericList = new CheckedJavaResource(
       "test.refresh", "GenericList") {
     @Override
     public void check(JClassType type) throws NotFoundException {
       assertNotNull(type.isGenericType());
     }
 
+    @Override
     public String getSource() {
       StringBuilder sb = new StringBuilder();
       sb.append("package test.refresh;\n");
@@ -416,12 +442,14 @@
     }
   };
 
-  protected CheckedMockCompilationUnit CU_HasSyntaxErrors = new CheckedMockCompilationUnit(
+  protected CheckedJavaResource CU_HasSyntaxErrors = new CheckedJavaResource(
       "test", "HasSyntaxErrors", "NoSyntaxErrors") {
+    @Override
     public void check(JClassType classInfo) {
       fail("This class should have been removed");
     }
 
+    @Override
     public String getSource() {
       StringBuffer sb = new StringBuffer();
       sb.append("package test;\n");
@@ -431,12 +459,14 @@
     }
   };
 
-  protected CheckedMockCompilationUnit CU_HasUnresolvedSymbols = new CheckedMockCompilationUnit(
+  protected CheckedJavaResource CU_HasUnresolvedSymbols = new CheckedJavaResource(
       "test", "Invalid", "Valid") {
+    @Override
     public void check(JClassType classInfo) {
       fail("Both classes should have been removed");
     }
 
+    @Override
     public String getSource() {
       StringBuffer sb = new StringBuffer();
       sb.append("package test;\n");
@@ -446,8 +476,8 @@
     }
   };
 
-  protected CheckedMockCompilationUnit CU_LocalClass = new CheckedMockCompilationUnit(
-      "test", "Enclosing", "Enclosing.1") {
+  protected CheckedJavaResource CU_LocalClass = new CheckedJavaResource("test",
+      "Enclosing", "Enclosing.1") {
 
     public void check(JClassType type) {
       final String name = type.getSimpleSourceName();
@@ -486,9 +516,10 @@
     }
   };
 
-  protected CheckedMockCompilationUnit CU_MethodsAndParams = new CheckedMockCompilationUnit(
+  protected CheckedJavaResource CU_MethodsAndParams = new CheckedJavaResource(
       "test", "Methods") {
 
+    @Override
     public void check(JClassType type) throws NotFoundException {
       TypeOracle tio = type.getOracle();
       JMethod[] methods = type.getMethods();
@@ -544,6 +575,7 @@
       assertEquals(0, thrownTypes.length);
     }
 
+    @Override
     public String getSource() {
       StringBuffer sb = new StringBuffer();
       sb.append("package test;\n");
@@ -559,13 +591,15 @@
     }
   };
 
-  protected CheckedMockCompilationUnit CU_Object = new CheckedMockCompilationUnit(
+  protected CheckedJavaResource CU_Object = new CheckedJavaResource(
       "java.lang", "Object") {
+    @Override
     public void check(JClassType type) {
       assertEquals("Object", type.getSimpleSourceName());
       assertEquals("java.lang.Object", type.getQualifiedSourceName());
     }
 
+    @Override
     public String getSource() {
       StringBuffer sb = new StringBuffer();
       sb.append("package java.lang;");
@@ -574,9 +608,10 @@
     }
   };
 
-  protected CheckedMockCompilationUnit CU_OuterInner = new CheckedMockCompilationUnit(
-      "test", "Outer", "Outer.Inner") {
+  protected CheckedJavaResource CU_OuterInner = new CheckedJavaResource("test",
+      "Outer", "Outer.Inner") {
 
+    @Override
     public void check(JClassType type) {
       final String name = type.getSimpleSourceName();
       if ("Outer".equals(name)) {
@@ -602,6 +637,7 @@
       assertEquals("test.Outer.Inner", inner.getQualifiedSourceName());
     }
 
+    @Override
     public String getSource() {
       StringBuffer sb = new StringBuffer();
       sb.append("package test;\n");
@@ -612,7 +648,7 @@
     }
   };
 
-  protected CheckedMockCompilationUnit CU_ReferencesGenericListConstant = new CheckedMockCompilationUnit(
+  protected CheckedJavaResource CU_ReferencesGenericListConstant = new CheckedJavaResource(
       "test.refresh", "ReferencesGenericListConstant") {
     @Override
     public void check(JClassType type) throws NotFoundException {
@@ -620,6 +656,7 @@
           type.getQualifiedSourceName());
     }
 
+    @Override
     public String getSource() {
       StringBuilder sb = new StringBuilder();
       sb.append("package test.refresh;\n");
@@ -630,7 +667,7 @@
     }
   };
 
-  protected CheckedMockCompilationUnit CU_ReferencesParameterizedTypeBeforeItsGenericFormHasBeenProcessed = new CheckedMockCompilationUnit(
+  protected CheckedJavaResource CU_ReferencesParameterizedTypeBeforeItsGenericFormHasBeenProcessed = new CheckedJavaResource(
       "parameterized.type.build.dependency", "Class0") {
     @Override
     public void check(JClassType type) throws NotFoundException {
@@ -639,6 +676,7 @@
       assertNotNull(intfs[0].isParameterized());
     }
 
+    @Override
     public String getSource() {
       StringBuilder sb = new StringBuilder();
       sb.append("package parameterized.type.build.dependency;\n");
@@ -648,12 +686,14 @@
     }
   };
 
-  protected CheckedMockCompilationUnit CU_RefsInfectedCompilationUnit = new CheckedMockCompilationUnit(
+  protected CheckedJavaResource CU_RefsInfectedCompilationUnit = new CheckedJavaResource(
       "test", "RefsInfectedCompilationUnit") {
+    @Override
     public void check(JClassType classInfo) {
       fail("This class should should have been removed because it refers to a class in another compilation unit that had problems");
     }
 
+    @Override
     public String getSource() {
       StringBuffer sb = new StringBuffer();
       sb.append("package test;\n");
@@ -662,13 +702,15 @@
     }
   };
 
-  protected CheckedMockCompilationUnit CU_Throwable = new CheckedMockCompilationUnit(
+  protected CheckedJavaResource CU_Throwable = new CheckedJavaResource(
       "java.lang", "Throwable") {
+    @Override
     public void check(JClassType type) {
       assertEquals("Throwable", type.getSimpleSourceName());
       assertEquals("java.lang.Throwable", type.getQualifiedSourceName());
     }
 
+    @Override
     public String getSource() {
       StringBuffer sb = new StringBuffer();
       sb.append("package java.lang;");
@@ -677,11 +719,9 @@
     }
   };
 
-  private final TypeOracleMediator mediator = new TypeOracleMediator();
+  private TypeOracle typeOracle;
 
-  private final TypeOracle typeOracle = mediator.getTypeOracle();
-
-  private final Set<CompilationUnit> units = new HashSet<CompilationUnit>();
+  private final Set<Resource> resources = new HashSet<Resource>();
 
   public void checkTypes(JClassType[] types) throws NotFoundException {
     for (JClassType type : types) {
@@ -736,9 +776,9 @@
   }
 
   public void testAssignable() throws TypeOracleException {
-    units.add(CU_Object);
-    units.add(CU_Assignable);
-    units.add(CU_OuterInner);
+    resources.add(CU_Object);
+    resources.add(CU_Assignable);
+    resources.add(CU_OuterInner);
     compileAndRefresh();
     JClassType[] allTypes = typeOracle.getTypes();
     assertEquals(7, allTypes.length);
@@ -773,66 +813,61 @@
   }
 
   public void testAssimilation() throws TypeOracleException {
-    units.add(CU_Object);
-    units.add(CU_BeforeAssimilate);
+    resources.add(CU_Object);
+    resources.add(CU_BeforeAssimilate);
     compileAndRefresh();
     assertEquals(2, typeOracle.getTypes().length);
-    JClassType before = typeOracle.findType("test.assim.BeforeAssimilate");
 
     // Build onto an existing type oracle.
-    units.add(CU_AfterAssimilate);
+    resources.add(CU_AfterAssimilate);
     compileAndRefresh();
     assertEquals(3, typeOracle.getTypes().length);
-
-    // Make sure identities remained intact across the assimilation.
-    JClassType after = typeOracle.findType("test.assim.AfterAssimilate");
-    assertSame(before, after.getSuperclass());
   }
 
   public void testBindToTypeScope() throws TypeOracleException {
-    units.add(CU_Object);
-    units.add(CU_BindToTypeScope);
+    resources.add(CU_Object);
+    resources.add(CU_BindToTypeScope);
     compileAndRefresh();
     JClassType[] types = typeOracle.getTypes();
     assertEquals(4, types.length);
   }
 
   public void testDefaultClass() throws TypeOracleException {
-    units.add(CU_Object);
-    units.add(CU_DefaultClass);
+    resources.add(CU_Object);
+    resources.add(CU_DefaultClass);
     compileAndRefresh();
     JClassType[] types = typeOracle.getTypes();
     assertEquals(2, types.length);
   }
 
   public void testFieldsAndTypes() throws TypeOracleException {
-    units.add(CU_Object);
-    units.add(CU_FieldsAndTypes);
+    resources.add(CU_Object);
+    resources.add(CU_FieldsAndTypes);
     compileAndRefresh();
     JClassType[] types = typeOracle.getTypes();
     assertEquals(3, types.length);
   }
 
   public void testLocal() throws TypeOracleException {
-    units.add(CU_Object);
-    units.add(CU_LocalClass);
+    resources.add(CU_Object);
+    resources.add(CU_LocalClass);
     compileAndRefresh();
     JClassType[] types = typeOracle.getTypes();
     assertEquals(3, types.length);
   }
 
   public void testMethodsAndParams() throws TypeOracleException {
-    units.add(CU_Object);
-    units.add(CU_Throwable);
-    units.add(CU_MethodsAndParams);
+    resources.add(CU_Object);
+    resources.add(CU_Throwable);
+    resources.add(CU_MethodsAndParams);
     compileAndRefresh();
     JClassType[] types = typeOracle.getTypes();
     assertEquals(3, types.length);
   }
 
   public void testOuterInner() throws TypeOracleException {
-    units.add(CU_Object);
-    units.add(CU_OuterInner);
+    resources.add(CU_Object);
+    resources.add(CU_OuterInner);
     compileAndRefresh();
     JClassType[] types = typeOracle.getTypes();
     assertEquals(3, types.length);
@@ -848,10 +883,10 @@
    */
   public void testParameterizedTypeBuildDependencies()
       throws TypeOracleException {
-    units.add(CU_ReferencesParameterizedTypeBeforeItsGenericFormHasBeenProcessed);
-    units.add(CU_ExtendsParameterizedType);
-    units.add(CU_DeclaresInnerGenericType);
-    units.add(CU_Object);
+    resources.add(CU_ReferencesParameterizedTypeBeforeItsGenericFormHasBeenProcessed);
+    resources.add(CU_ExtendsParameterizedType);
+    resources.add(CU_DeclaresInnerGenericType);
+    resources.add(CU_Object);
 
     compileAndRefresh();
     assertNull(typeOracle.findType("test.parameterizedtype.build.dependencies.Class2"));
@@ -866,24 +901,23 @@
    * @throws IOException
    */
   public void testRefresh() throws TypeOracleException {
-    units.add(CU_Object);
-    units.add(CU_ExtendsGenericList);
-    units.add(CU_GenericList);
-    units.add(CU_ReferencesGenericListConstant);
+    resources.add(CU_Object);
+    resources.add(CU_ExtendsGenericList);
+    resources.add(CU_GenericList);
+    resources.add(CU_ReferencesGenericListConstant);
 
     compileAndRefresh();
 
     // Get the types produced by the TypeOracle
     JClassType extendsGenericListType = typeOracle.getType("test.refresh.ExtendsGenericList");
     JClassType genericListType = typeOracle.getType("test.refresh.GenericList");
-    JClassType objectType = typeOracle.getJavaLangObject();
     JClassType referencesGenericListConstantType = typeOracle.getType("test.refresh.ReferencesGenericListConstant");
 
     /*
      * Invalidate CU_GenericList and simulate a refresh. This should cause
      * anything that depends on GenericList to be rebuilt by the type oracle.
      */
-    CU_GenericList.setFresh();
+    CU_GenericList.touch();
     compileAndRefresh();
 
     assertNotSame(genericListType.getQualifiedSourceName() + "; ",
@@ -891,8 +925,6 @@
     assertNotSame(extendsGenericListType.getQualifiedSourceName() + "; ",
         typeOracle.getType("test.refresh.ExtendsGenericList"),
         extendsGenericListType);
-    assertSame(objectType.getQualifiedSourceName() + "; ",
-        typeOracle.getJavaLangObject(), objectType);
 
     /*
      * Make sure that referencing a constant field will cause a type to be
@@ -920,13 +952,13 @@
     StringBuffer sb = new StringBuffer();
     sb.append("package java.lang;");
     sb.append("public class Object { }");
-    addCompilationUnit("java.lang.Object", sb);
+    addResource("java.lang.Object", sb);
 
     // Add UnmodifiedClass that will never change.
     sb = new StringBuffer();
     sb.append("package test.refresh.with.errors;");
     sb.append("public class UnmodifiedClass { }");
-    addCompilationUnit("test.refresh.with.errors.UnmodifiedClass", sb);
+    addResource("test.refresh.with.errors.UnmodifiedClass", sb);
 
     // Add GoodClass that references a class that will go bad.
     sb = new StringBuffer();
@@ -934,10 +966,10 @@
     sb.append("public class GoodClass {\n");
     sb.append("  ClassThatWillGoBad ctwgb;\n");
     sb.append("}\n");
-    addCompilationUnit("test.refresh.with.errors.GoodClass", sb);
+    addResource("test.refresh.with.errors.GoodClass", sb);
 
     // Add ClassThatWillGoBad that goes bad on the next refresh.
-    MockCompilationUnit unitThatWillGoBad = new MockCompilationUnit(
+    MutableJavaResource unitThatWillGoBad = new MutableJavaResource(
         "test.refresh.with.errors.ClassThatWillGoBad") {
       private String source = "package test.refresh.with.errors;\n"
           + "public class ClassThatWillGoBad { }\n";
@@ -948,12 +980,12 @@
       }
 
       @Override
-      void setFresh() {
-        super.setFresh();
+      public void touch() {
+        super.touch();
         source = "This will cause a syntax error.";
       }
     };
-    units.add(unitThatWillGoBad);
+    resources.add(unitThatWillGoBad);
 
     compileAndRefresh();
 
@@ -968,7 +1000,7 @@
     sb.append("public class AnotherGoodClass {\n");
     sb.append("  UnmodifiedClass uc; // This will cause the runaway pruning.\n");
     sb.append("}\n");
-    addCompilationUnit("test.refresh.with.errors.AnotherGoodClass", sb);
+    addResource("test.refresh.with.errors.AnotherGoodClass", sb);
 
     // Add BadClass that has errors and originally
     // forced issue 2238.
@@ -977,10 +1009,10 @@
     sb.append("public class BadClass {\n");
     sb.append("  This will trigger a syntax error.\n");
     sb.append("}\n");
-    addCompilationUnit("test.refresh.with.errors.BadClass", sb);
+    addResource("test.refresh.with.errors.BadClass", sb);
 
     // Now this cup should cause errors.
-    unitThatWillGoBad.setFresh();
+    unitThatWillGoBad.touch();
 
     compileAndRefresh();
 
@@ -992,8 +1024,8 @@
   }
 
   public void testSyntaxErrors() throws TypeOracleException {
-    units.add(CU_Object);
-    units.add(CU_HasSyntaxErrors);
+    resources.add(CU_Object);
+    resources.add(CU_HasSyntaxErrors);
     compileAndRefresh();
     JClassType[] types = typeOracle.getTypes();
     // Only java.lang.Object should remain.
@@ -1003,9 +1035,9 @@
   }
 
   public void testUnresolvedSymbls() throws TypeOracleException {
-    units.add(CU_Object);
-    units.add(CU_HasUnresolvedSymbols);
-    units.add(CU_RefsInfectedCompilationUnit);
+    resources.add(CU_Object);
+    resources.add(CU_HasUnresolvedSymbols);
+    resources.add(CU_RefsInfectedCompilationUnit);
     compileAndRefresh();
     JClassType[] types = typeOracle.getTypes();
     // Only java.lang.Object should remain.
@@ -1015,30 +1047,25 @@
   }
 
   /**
-   * Creates a {@link CompilationUnit} and adds it the set of units.
+   * Creates a {@link Resource} and adds it the set of resources.
    * 
    * @throws UnableToCompleteException
    */
-  private void addCompilationUnit(String qualifiedTypeName, CharSequence source) {
-    units.add(new MockCompilationUnit(qualifiedTypeName, source.toString()));
+  private void addResource(String qualifiedTypeName, CharSequence source) {
+    resources.add(new StaticJavaResource(qualifiedTypeName, source));
   }
 
   private void check(JClassType classInfo) throws NotFoundException {
     final String qName = classInfo.getQualifiedSourceName();
-    CheckedMockCompilationUnit cup = publicTypeNameToTestCupMap.get(qName);
+    CheckedJavaResource cup = publicTypeNameToTestCupMap.get(qName);
     if (cup != null) {
       cup.check(classInfo);
     }
   }
 
   private void compileAndRefresh() throws TypeOracleException {
-    TreeLogger logger = createTreeLogger();
-    CompilationUnitInvalidator.invalidateUnitsWithInvalidRefs(logger, units);
-    JdtCompiler.compile(units);
-    if (CompilationUnitInvalidator.invalidateUnitsWithErrors(logger, units)) {
-      CompilationUnitInvalidator.invalidateUnitsWithInvalidRefs(logger, units);
-    }
-    mediator.refresh(logger, units);
+    typeOracle = TypeOracleTestingUtils.buildTypeOracle(createTreeLogger(),
+        resources);
     checkTypes(typeOracle.getTypes());
   }
 
@@ -1056,7 +1083,7 @@
     }
   }
 
-  private void register(String qualifiedTypeName, CheckedMockCompilationUnit cup) {
+  private void register(String qualifiedTypeName, CheckedJavaResource cup) {
     publicTypeNameToTestCupMap.put(qualifiedTypeName, cup);
   }
 }
diff --git a/dev/core/test/com/google/gwt/dev/javac/TypeOracleTestingUtils.java b/dev/core/test/com/google/gwt/dev/javac/TypeOracleTestingUtils.java
index 8191e11..8ec84b2 100644
--- a/dev/core/test/com/google/gwt/dev/javac/TypeOracleTestingUtils.java
+++ b/dev/core/test/com/google/gwt/dev/javac/TypeOracleTestingUtils.java
@@ -17,10 +17,11 @@
 
 import com.google.gwt.core.ext.TreeLogger;
 import com.google.gwt.core.ext.typeinfo.TypeOracle;
+import com.google.gwt.dev.javac.CompilationStateTestBase.GeneratedSourceFileCompilationUnit;
 import com.google.gwt.dev.javac.impl.JavaResourceBase;
-import com.google.gwt.dev.javac.impl.MockJavaResource;
-import com.google.gwt.dev.javac.impl.SourceFileCompilationUnit;
+import com.google.gwt.dev.resource.Resource;
 
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
@@ -32,50 +33,67 @@
 public class TypeOracleTestingUtils {
 
   public static TypeOracle buildStandardTypeOracleWith(TreeLogger logger,
-      CompilationUnit... extraUnits) {
-    Set<CompilationUnit> extraUnitSet = new HashSet<CompilationUnit>();
-    Collections.addAll(extraUnitSet, extraUnits);
-    return buildStandardTypeOracleWith(logger, extraUnitSet);
+      Resource... resources) {
+    return buildStandardTypeOracleWith(logger, new HashSet<Resource>(
+        Arrays.asList(resources)));
   }
 
   public static TypeOracle buildStandardTypeOracleWith(TreeLogger logger,
-      Set<CompilationUnit> extraUnits) {
-    Set<CompilationUnit> unitSet = new HashSet<CompilationUnit>();
-    addStandardCups(unitSet);
-    for (CompilationUnit extraUnit : extraUnits) {
-      unitSet.add(extraUnit);
-    }
-    return buildTypeOracle(logger, unitSet);
+      Set<Resource> resources) {
+    return buildTypeOracle(logger, standardBuildersPlus(resources));
+  }
+
+  public static TypeOracle buildStandardTypeOracleWith(TreeLogger logger,
+      Set<Resource> resources, Set<GeneratedUnit> generatedUnits) {
+    return buildTypeOracle(logger, standardBuildersPlus(resources),
+        generatedUnits);
+  }
+
+  public static void buildStandardTypeOracleWith(TypeOracleMediator mediator,
+      TreeLogger logger, Resource... resources) {
+    buildStandardTypeOracleWith(mediator, logger, new HashSet<Resource>(
+        Arrays.asList(resources)));
+  }
+
+  public static void buildStandardTypeOracleWith(TypeOracleMediator mediator,
+      TreeLogger logger, Set<Resource> resources) {
+    buildTypeOracle(mediator, logger, standardBuildersPlus(resources));
   }
 
   public static TypeOracle buildTypeOracle(TreeLogger logger,
-      Set<CompilationUnit> units) {
-    Set<String> validBinaryTypeNames = new HashSet<String>();
-    for (CompilationUnit unit : units) {
-      Set<CompiledClass> compiledClasses = unit.getCompiledClasses();
-      if (compiledClasses != null) {
-        for (CompiledClass compiledClass : compiledClasses) {
-          validBinaryTypeNames.add(compiledClass.getInternalName());
-        }
-      }
+      Set<Resource> resources) {
+    return buildTypeOracle(logger, resources,
+        Collections.<GeneratedUnit> emptySet());
+  }
+
+  public static TypeOracle buildTypeOracle(TreeLogger logger,
+      Set<Resource> resources, Set<GeneratedUnit> generatedUnits) {
+    CompilationState state = CompilationStateBuilder.buildFrom(logger,
+        resources);
+    Set<CompilationUnit> units = new HashSet<CompilationUnit>();
+    for (GeneratedUnit unit : generatedUnits) {
+      units.add(new GeneratedSourceFileCompilationUnit(unit));
     }
-    JdtCompiler.compile(units);
-    CompilationUnitInvalidator.InvalidatorState state = new CompilationUnitInvalidator.InvalidatorState();
-    CompilationUnitInvalidator.validateCompilationUnits(state, units);
-    if (CompilationUnitInvalidator.invalidateUnitsWithErrors(logger, units)) {
-      CompilationUnitInvalidator.invalidateUnitsWithInvalidRefs(logger, units);
-    }
-    TypeOracleMediator mediator = new TypeOracleMediator();
-    mediator.refresh(logger, units);
-    return mediator.getTypeOracle();
+    state.addGeneratedCompilationUnits(logger, units);
+    return state.getTypeOracle();
+  }
+
+  public static void buildTypeOracle(TypeOracleMediator mediator,
+      TreeLogger logger, Set<Resource> resources) {
+    CompilationState state = CompilationStateBuilder.buildFrom(logger,
+        resources);
+    mediator.addNewUnits(logger, state.getCompilationUnits());
   }
 
   /**
-   * Add compilation units for basic classes like Object and String.
+   * Compilation resources for basic classes like Object and String.
    */
-  private static void addStandardCups(Set<CompilationUnit> units) {
-    for (MockJavaResource resource : JavaResourceBase.getStandardResources()) {
-      units.add(new SourceFileCompilationUnit(resource));
+  private static Set<Resource> standardBuildersPlus(Set<Resource> resources) {
+    Set<Resource> result = new HashSet<Resource>();
+    for (Resource standardResource : JavaResourceBase.getStandardResources()) {
+      result.add(standardResource);
     }
+    result.addAll(resources);
+    return result;
   }
 }
diff --git a/dev/core/test/com/google/gwt/dev/javac/impl/JdtBehaviorTest.java b/dev/core/test/com/google/gwt/dev/javac/impl/JdtBehaviorTest.java
index 34b4012..17884cf 100644
--- a/dev/core/test/com/google/gwt/dev/javac/impl/JdtBehaviorTest.java
+++ b/dev/core/test/com/google/gwt/dev/javac/impl/JdtBehaviorTest.java
@@ -149,7 +149,7 @@
     }
 
     public char[] getContents() {
-      return SourceFileCompilationUnit.readSource(sourceFile).toCharArray();
+      return Shared.readSource(sourceFile).toCharArray();
     }
 
     public char[] getFileName() {
@@ -157,13 +157,12 @@
     }
 
     public char[] getMainTypeName() {
-      return Shared.getShortName(
-          SourceFileCompilationUnit.getTypeName(sourceFile)).toCharArray();
+      return Shared.getShortName(Shared.getTypeName(sourceFile)).toCharArray();
     }
 
     public char[][] getPackageName() {
       return CharOperation.splitOn('.', Shared.getPackageName(
-          SourceFileCompilationUnit.getTypeName(sourceFile)).toCharArray());
+          Shared.getTypeName(sourceFile)).toCharArray());
     }
 
     @Override
diff --git a/dev/core/test/com/google/gwt/dev/javac/impl/MockResource.java b/dev/core/test/com/google/gwt/dev/javac/impl/MockResource.java
index 9c99761..00479ab 100644
--- a/dev/core/test/com/google/gwt/dev/javac/impl/MockResource.java
+++ b/dev/core/test/com/google/gwt/dev/javac/impl/MockResource.java
@@ -20,13 +20,29 @@
 
 import java.io.ByteArrayInputStream;
 import java.io.InputStream;
-import java.net.URL;
+import java.util.concurrent.atomic.AtomicLong;
 
 /**
  * An in-memory {@link Resource}.
  */
 public abstract class MockResource extends Resource {
+  private static final AtomicLong lastTimeStamp = new AtomicLong();
+
+  private static long getNextCreationTime() {
+    long currentTime = System.currentTimeMillis();
+    long lastTime;
+    // Go into the future until we succeed.
+    do {
+      lastTime = lastTimeStamp.get();
+      if (currentTime <= lastTime) {
+        currentTime = lastTime + 1;
+      }
+    } while (!lastTimeStamp.compareAndSet(lastTime, currentTime));
+    return currentTime;
+  }
+
   private final String path;
+  private final long creationTime = getNextCreationTime();
 
   public MockResource(String path) {
     this.path = path;
@@ -34,7 +50,7 @@
 
   @Override
   public long getLastModified() {
-    return 0;
+    return creationTime;
   }
 
   @Override
@@ -47,6 +63,10 @@
     return path;
   }
 
+  public String getString() {
+    return getContent().toString();
+  }
+
   @Override
   public InputStream openContents() {
     return new ByteArrayInputStream(Util.getBytes(getContent().toString()));
diff --git a/dev/core/test/com/google/gwt/dev/javac/impl/StaticJavaResource.java b/dev/core/test/com/google/gwt/dev/javac/impl/StaticJavaResource.java
new file mode 100644
index 0000000..1b8564f
--- /dev/null
+++ b/dev/core/test/com/google/gwt/dev/javac/impl/StaticJavaResource.java
@@ -0,0 +1,31 @@
+/*

+ * Copyright 2009 Google Inc.

+ * 

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not

+ * use this file except in compliance with the License. You may obtain a copy of

+ * the License at

+ * 

+ * http://www.apache.org/licenses/LICENSE-2.0

+ * 

+ * Unless required by applicable law or agreed to in writing, software

+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT

+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the

+ * License for the specific language governing permissions and limitations under

+ * the License.

+ */

+package com.google.gwt.dev.javac.impl;

+

+public class StaticJavaResource extends MockResource {

+

+  private final CharSequence source;

+

+  public StaticJavaResource(String typeName, CharSequence source) {

+    super(Shared.toPath(typeName));

+    this.source = source;

+  }

+

+  @Override

+  protected CharSequence getContent() {

+    return source;

+  }

+}

diff --git a/dev/core/test/com/google/gwt/dev/javac/impl/TweakedMockJavaResource.java b/dev/core/test/com/google/gwt/dev/javac/impl/TweakedMockJavaResource.java
new file mode 100644
index 0000000..8e57cb8
--- /dev/null
+++ b/dev/core/test/com/google/gwt/dev/javac/impl/TweakedMockJavaResource.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2009 Google Inc.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.dev.javac.impl;
+
+public class TweakedMockJavaResource extends MockJavaResource {
+
+  private MockJavaResource original;
+
+  public TweakedMockJavaResource(MockJavaResource original) {
+    super(original.getTypeName());
+    this.original = original;
+  }
+
+  @Override
+  public CharSequence getContent() {
+    return original.getContent() + "\n";
+  }
+}
diff --git a/dev/core/test/com/google/gwt/dev/jjs/impl/OptimizerTestBase.java b/dev/core/test/com/google/gwt/dev/jjs/impl/OptimizerTestBase.java
index 50cf016..651c312 100644
--- a/dev/core/test/com/google/gwt/dev/jjs/impl/OptimizerTestBase.java
+++ b/dev/core/test/com/google/gwt/dev/jjs/impl/OptimizerTestBase.java
@@ -18,6 +18,7 @@
 import com.google.gwt.core.ext.TreeLogger;
 import com.google.gwt.core.ext.UnableToCompleteException;
 import com.google.gwt.dev.javac.CompilationState;
+import com.google.gwt.dev.javac.CompilationStateBuilder;
 import com.google.gwt.dev.javac.impl.MockJavaResource;
 import com.google.gwt.dev.javac.impl.MockResourceOracle;
 import com.google.gwt.dev.jjs.JavaAstConstructor;
@@ -77,8 +78,8 @@
 
   /**
    * Finds a type by name. The type name may be short, e.g. <code>"Foo"</code>,
-   * or fully-qualified, e.g. <code>"com.google.example.Foo"</code>. If a short
-   * name is used, it must be unambiguous.
+   * or fully-qualified, e.g. <code>"com.google.example.Foo"</code>. If a
+   * short name is used, it must be unambiguous.
    */
   public static JDeclaredType findType(JProgram program, String typeName) {
     JDeclaredType type = program.getFromTypeMap(typeName);
@@ -125,9 +126,6 @@
 
   private final Set<String> snippetImports = new TreeSet<String>();
 
-  private final CompilationState state = new CompilationState(logger,
-      sourceOracle);
-
   public OptimizerTestBase() {
     sourceOracle.add(JavaAstConstructor.getCompilerTypes());
   }
@@ -178,8 +176,8 @@
         return code;
       }
     });
-    state.refresh(logger);
-
+    CompilationState state = CompilationStateBuilder.buildFrom(logger,
+        sourceOracle.getResources());
     JProgram program = JavaAstConstructor.construct(logger, state,
         "test.EntryPoint");
     return program;
diff --git a/dev/core/test/com/google/gwt/dev/shell/StandardGeneratorContextTest.java b/dev/core/test/com/google/gwt/dev/shell/StandardGeneratorContextTest.java
index 2581868..b0fcc9e 100644
--- a/dev/core/test/com/google/gwt/dev/shell/StandardGeneratorContextTest.java
+++ b/dev/core/test/com/google/gwt/dev/shell/StandardGeneratorContextTest.java
@@ -28,8 +28,8 @@
 import com.google.gwt.core.ext.linker.GeneratedResource;
 import com.google.gwt.dev.cfg.ModuleDef;
 import com.google.gwt.dev.javac.CompilationState;
+import com.google.gwt.dev.javac.CompilationStateBuilder;
 import com.google.gwt.dev.javac.StandardGeneratorContext;
-import com.google.gwt.dev.javac.impl.MockResourceOracle;
 import com.google.gwt.dev.resource.Resource;
 import com.google.gwt.dev.util.Util;
 
@@ -42,9 +42,9 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.UnsupportedEncodingException;
-import java.net.URL;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 
 /**
@@ -52,14 +52,6 @@
  */
 public class StandardGeneratorContextTest extends TestCase {
 
-  public static class MockCompilationState extends CompilationState {
-
-    public MockCompilationState() {
-      super(TreeLogger.NULL, new MockResourceOracle());
-    }
-
-  }
-
   private static class MockGenerator extends Generator {
     @Override
     public String generate(TreeLogger logger, GeneratorContext context,
@@ -134,7 +126,8 @@
 
   private final ArtifactSet artifactSet = new ArtifactSet();
   private final StandardGeneratorContext genCtx;
-  private final CompilationState mockCompilationState = new MockCompilationState();
+  private final CompilationState mockCompilationState = CompilationStateBuilder.buildFrom(
+      TreeLogger.NULL, Collections.<Resource> emptySet());
   private final TreeLogger mockLogger = TreeLogger.NULL;
   private final PropertyOracle mockPropOracle = new MockPropertyOracle();
   private int tempFileCounter;
diff --git a/tools/api-checker/build.xml b/tools/api-checker/build.xml
index a26c585..5eb8c35 100755
--- a/tools/api-checker/build.xml
+++ b/tools/api-checker/build.xml
@@ -21,7 +21,16 @@
     </gwt.javac>
   </target>
 
-  <target name="compile.tests" depends="compile.emma.if.enabled" description="Compiles the test code for this project">
+  <!--
+    Compiles test dependencies in dev/core
+  -->
+  <target name="compile.dev.tests">
+    <gwt.ant dir="../../dev" target="compile.tests" />
+  </target>
+
+  <target name="compile.tests"
+      depends="compile.dev.tests, compile.emma.if.enabled"
+      description="Compiles the test code for this project">
     <mkdir dir="${javac.junit.out}" />
     <gwt.javac srcdir="test" destdir="${javac.junit.out}">
       <classpath>
@@ -29,12 +38,13 @@
         <pathelement location="${gwt.tools.lib}/junit/junit-3.8.1.jar" />
         <pathelement location="${gwt.dev.staging.jar}" />
         <pathelement location="${gwt.dev.jar}" />
+        <pathelement location="${gwt.build.out}/dev/bin-test" />
         <pathelement location="${gwt.user.jar}" />
       </classpath>
     </gwt.javac>
   </target>
         
-        <target name="build" depends="compile" description="Build and package this project">
+  <target name="build" depends="compile" description="Build and package this project">
     <mkdir dir="${gwt.build.lib}" />
                     
     <gwt.jar>
@@ -49,6 +59,7 @@
       <extraclasspaths>
         <pathelement location="${gwt.build.out}/tools/api-checker/bin"/>
         <pathelement location="${gwt.dev.jar}" />
+        <pathelement location="${gwt.build.out}/dev/bin-test" />
       </extraclasspaths>
     </gwt.junit>
   </target>
diff --git a/tools/api-checker/src/com/google/gwt/tools/apichecker/ApiCompatibilityChecker.java b/tools/api-checker/src/com/google/gwt/tools/apichecker/ApiCompatibilityChecker.java
index 804dcdf..b4b6687 100644
--- a/tools/api-checker/src/com/google/gwt/tools/apichecker/ApiCompatibilityChecker.java
+++ b/tools/api-checker/src/com/google/gwt/tools/apichecker/ApiCompatibilityChecker.java
@@ -18,8 +18,9 @@
 import com.google.gwt.core.ext.TreeLogger;
 import com.google.gwt.core.ext.UnableToCompleteException;
 import com.google.gwt.core.ext.typeinfo.NotFoundException;
-import com.google.gwt.dev.javac.CompilationUnit;
-import com.google.gwt.dev.javac.impl.FileCompilationUnit;
+import com.google.gwt.dev.javac.impl.Shared;
+import com.google.gwt.dev.resource.Resource;
+import com.google.gwt.dev.util.Util;
 import com.google.gwt.dev.util.log.AbstractTreeLogger;
 import com.google.gwt.dev.util.log.PrintWriterTreeLogger;
 import com.google.gwt.util.tools.ArgHandlerFlag;
@@ -30,6 +31,7 @@
 
 import java.io.BufferedInputStream;
 import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
@@ -93,43 +95,82 @@
 
   // TODO(amitmanjhi): better handling of exceptions and exception-chaining.
 
-  static class StaticCompilationUnit extends CompilationUnit {
+  static class FileResource extends Resource {
+    private final File file;
+    private final String path;
 
-    private final String source;
-    private final String typeName;
-
-    public StaticCompilationUnit(String typeName, String source) {
-      this.typeName = typeName;
-      this.source = source;
-    }
-
-    @Override
-    public String getDisplayLocation() {
-      return "/mock/" + typeName;
+    public FileResource(File file, String path) {
+      this.file = file;
+      this.path = path;
+      assert path.endsWith(".java");
+      assert file.getAbsolutePath().endsWith(path);
     }
 
     @Override
     public long getLastModified() {
-      return 0;
+      return file.lastModified();
     }
 
     @Override
-    public String getSource() {
-      return String.valueOf(source);
+    public String getLocation() {
+      return file.getAbsolutePath();
     }
 
     @Override
-    public String getTypeName() {
-      return typeName;
+    public String getPath() {
+      return path;
     }
 
     @Override
-    public boolean isGenerated() {
+    public InputStream openContents() {
+      try {
+        return new FileInputStream(file);
+      } catch (FileNotFoundException e) {
+        throw new RuntimeException("Unable to open file '"
+            + file.getAbsolutePath() + "'", e);
+      }
+    }
+
+    @Override
+    public boolean wasRerooted() {
       return false;
     }
+  }
+
+  static class StaticResource extends Resource {
+
+    private final long lastModified;
+    private final String source;
+    private final String typeName;
+
+    public StaticResource(String typeName, String source, long lastModified) {
+      this.typeName = typeName;
+      this.source = source;
+      this.lastModified = lastModified;
+    }
 
     @Override
-    public boolean isSuperSource() {
+    public long getLastModified() {
+      return lastModified;
+    }
+
+    @Override
+    public String getLocation() {
+      return "/mock/" + getPath();
+    }
+
+    @Override
+    public String getPath() {
+      return Shared.toPath(typeName);
+    }
+
+    @Override
+    public InputStream openContents() {
+      return new ByteArrayInputStream(Util.getBytes(source));
+    }
+
+    @Override
+    public boolean wasRerooted() {
       return false;
     }
   }
@@ -137,15 +178,15 @@
   /**
    * Abstract internal class that specifies a set of {@link CompilationUnit}.
    */
-  private abstract static class CompilationUnits {
+  private abstract static class Resources {
     protected final TreeLogger logger;
 
-    CompilationUnits(TreeLogger logger) {
+    Resources(TreeLogger logger) {
       this.logger = logger;
     }
 
-    public abstract Set<CompilationUnit> getCompilationUnits()
-        throws NotFoundException, IOException, UnableToCompleteException;
+    public abstract Set<Resource> getResources() throws NotFoundException,
+        IOException, UnableToCompleteException;
 
     // TODO (amitmanjhi): remove this code. use TypeOracle functionality
     // instead.
@@ -196,13 +237,13 @@
   /**
    * Class that specifies a set of {@link CompilationUnit} read from jar files.
    */
-  private static class JarFileCompilationUnits extends CompilationUnits {
+  private static class JarFileResources extends Resources {
+    private final ZipScanner excludeScanner;
     private final Set<String> includedPaths;
     private final JarFile jarFiles[];
-    private Set<CompilationUnit> units = null;
-    private final ZipScanner excludeScanner;
+    private Set<Resource> resources = null;
 
-    JarFileCompilationUnits(JarFile[] jarFiles, Set<String> includedPaths,
+    JarFileResources(JarFile[] jarFiles, Set<String> includedPaths,
         Set<String> excludedPaths, TreeLogger logger) {
       super(logger);
       this.jarFiles = jarFiles;
@@ -218,12 +259,12 @@
     }
 
     @Override
-    public Set<CompilationUnit> getCompilationUnits() throws IOException {
-      if (units != null) {
-        return units;
+    public Set<Resource> getResources() throws IOException {
+      if (resources != null) {
+        return resources;
       }
 
-      units = new HashSet<CompilationUnit>();
+      resources = new HashSet<Resource>();
       for (JarFile jarFile : jarFiles) {
         Enumeration<JarEntry> entries = jarFile.entries();
         while (entries.hasMoreElements()) {
@@ -240,8 +281,12 @@
             } else {
               if (isValidPackage(packageName, fileName)) {
                 // Add if package and fileNames are okay
-                units.add(new StaticCompilationUnit(packageName + "."
-                    + getClassName(fileName), fileContent));
+                long lastModified = jarEntry.getTime();
+                if (lastModified < 0) {
+                  lastModified = System.currentTimeMillis();
+                }
+                resources.add(new StaticResource(packageName + "."
+                    + getClassName(fileName), fileContent, lastModified));
                 logger.log(TreeLogger.DEBUG, "adding pkgName = " + packageName
                     + ", file = " + fileName, null);
               } else {
@@ -252,7 +297,7 @@
           }
         }
       }
-      return units;
+      return resources;
     }
 
     String getFileContentsFromJar(JarFile jarFile, JarEntry jarEntry)
@@ -301,14 +346,14 @@
    * Class that specifies a set of {@link CompilationUnit} read from the
    * file-system.
    */
-  private static class SourceFileCompilationUnits extends CompilationUnits {
-    private final Set<File> includedPaths;
-    private Set<CompilationUnit> units = null;
+  private static class SourceFileResources extends Resources {
     private final ZipScanner excludeScanner;
+    private final Set<File> includedPaths;
+    private Set<Resource> units = null;
 
-    SourceFileCompilationUnits(String dirRoot,
-        Set<String> includedPathsAsString, Set<String> excludedPathsAsString,
-        TreeLogger logger) throws FileNotFoundException, IOException {
+    SourceFileResources(String dirRoot, Set<String> includedPathsAsString,
+        Set<String> excludedPathsAsString, TreeLogger logger)
+        throws FileNotFoundException, IOException {
       super(logger);
       if (dirRoot == null) {
         dirRoot = "";
@@ -337,13 +382,13 @@
     }
 
     @Override
-    public Set<CompilationUnit> getCompilationUnits() throws NotFoundException,
-        IOException, UnableToCompleteException {
+    public Set<Resource> getResources() throws NotFoundException, IOException,
+        UnableToCompleteException {
       if (units != null) {
         return units;
       }
 
-      units = new HashSet<CompilationUnit>();
+      units = new HashSet<Resource>();
       for (File sourceFile : includedPaths) {
         updateCompilationUnitsInPath(sourceFile);
       }
@@ -381,9 +426,11 @@
           continue;
         }
         if (file.isFile()) {
-          String pkgName = null;
+          String fileName = file.getName();
           if (file.getName().endsWith("java")) {
-            pkgName = extractPackageName(new FileReader(file));
+            String className = file.getName().substring(0,
+                fileName.length() - 5);
+            String pkgName = extractPackageName(new FileReader(file));
             if (pkgName == null) {
               logger.log(TreeLogger.WARN, "Not adding file = "
                   + file.toString() + ", because packageName = null", null);
@@ -391,7 +438,8 @@
               if (isValidPackage(pkgName,
                   sourcePathEntry.toURI().toURL().toString())) {
                 // Add if the package and fileNames are okay
-                units.add(new FileCompilationUnit(file, pkgName));
+                String typeName = Shared.makeTypeName(pkgName, className);
+                units.add(new FileResource(file, Shared.toPath(typeName)));
                 logger.log(TreeLogger.DEBUG, "adding pkgName = " + pkgName
                     + ", file = " + file.toString(), null);
               } else {
@@ -473,34 +521,34 @@
 
       Set<String> excludedPackages = checker.getSetOfExcludedPackages(checker.configProperties);
       if (PROCESS_NEW_API) {
-        Set<CompilationUnit> units = new HashSet<CompilationUnit>();
-        units.addAll(new SourceFileCompilationUnits(
+        Set<Resource> resources = new HashSet<Resource>();
+        resources.addAll(new SourceFileResources(
             checker.configProperties.getProperty("dirRoot_new"),
             checker.getConfigPropertyAsSet("sourceFiles_new"),
-            checker.getConfigPropertyAsSet("excludedFiles_new"), logger).getCompilationUnits());
-        units.addAll(checker.getGwtCompilationUnits(logger));
+            checker.getConfigPropertyAsSet("excludedFiles_new"), logger).getResources());
+        resources.addAll(checker.getGwtCompilationUnits(logger));
         newApi = new ApiContainer(
-            checker.configProperties.getProperty("name_new"), units,
+            checker.configProperties.getProperty("name_new"), resources,
             excludedPackages, logger);
         if (checker.printAllApi) {
           logger.log(TreeLogger.INFO, newApi.getApiAsString());
         }
       }
       if (PROCESS_EXISTING_API) {
-        Set<CompilationUnit> units = new HashSet<CompilationUnit>();
+        Set<Resource> resources = new HashSet<Resource>();
         if (checker.refJars == null) {
-          units.addAll(new SourceFileCompilationUnits(
+          resources.addAll(new SourceFileResources(
               checker.configProperties.getProperty("dirRoot_old"),
               checker.getConfigPropertyAsSet("sourceFiles_old"),
-              checker.getConfigPropertyAsSet("excludedFiles_old"), logger).getCompilationUnits());
+              checker.getConfigPropertyAsSet("excludedFiles_old"), logger).getResources());
         } else {
-          units.addAll(new JarFileCompilationUnits(checker.refJars,
+          resources.addAll(new JarFileResources(checker.refJars,
               checker.getConfigPropertyAsSet("sourceFiles_old"),
-              checker.getConfigPropertyAsSet("excludedFiles_old"), logger).getCompilationUnits());
+              checker.getConfigPropertyAsSet("excludedFiles_old"), logger).getResources());
         }
-        units.addAll(checker.getGwtCompilationUnits(logger));
+        resources.addAll(checker.getGwtCompilationUnits(logger));
         existingApi = new ApiContainer(
-            checker.configProperties.getProperty("name_old"), units,
+            checker.configProperties.getProperty("name_old"), resources,
             excludedPackages, logger);
         if (checker.printAllApi) {
           logger.log(TreeLogger.INFO, existingApi.getApiAsString());
@@ -846,10 +894,10 @@
     return set;
   }
 
-  private Set<CompilationUnit> getGwtCompilationUnits(TreeLogger logger)
+  private Set<Resource> getGwtCompilationUnits(TreeLogger logger)
       throws FileNotFoundException, IOException, NotFoundException,
       UnableToCompleteException {
-    Set<CompilationUnit> units = new HashSet<CompilationUnit>();
+    Set<Resource> resources = new HashSet<Resource>();
     if (gwtDevJar == null || gwtUserJar == null) {
       if (gwtDevJar != null) {
         System.err.println("Argument gwtUserJar must be provided for gwtDevJar to be used");
@@ -857,7 +905,7 @@
       if (gwtUserJar != null) {
         System.err.println("Argument gwtDevJar must be provided for gwtUserJar to be used");
       }
-      return units;
+      return resources;
     }
     // gwt-user.jar
     Set<String> gwtIncludedPaths = new HashSet<String>(
@@ -872,19 +920,19 @@
             "com/google/gwt/user/client/rpc/core/java/util/LinkedHashMap_CustomFieldSerializer.java",
             "com/google/gwt/user/rebind", "com/google/gwt/user/server",
             "com/google/gwt/user/tools",}));
-    CompilationUnits cu = new JarFileCompilationUnits(
-        new JarFile[] {gwtUserJar}, gwtIncludedPaths, gwtExcludedPaths, logger);
-    units.addAll(cu.getCompilationUnits());
+    Resources cu = new JarFileResources(new JarFile[] {gwtUserJar},
+        gwtIncludedPaths, gwtExcludedPaths, logger);
+    resources.addAll(cu.getResources());
 
     // gwt-dev-*.jar
     gwtIncludedPaths = new HashSet<String>(Arrays.asList(new String[] {
         "com/google/gwt/core/client",
         "com/google/gwt/dev/jjs/intrinsic/com/google/gwt/lang",
         "com/google/gwt/lang",}));
-    cu = new JarFileCompilationUnits(new JarFile[] {gwtDevJar},
-        gwtIncludedPaths, new HashSet<String>(), logger);
-    units.addAll(cu.getCompilationUnits());
-    return units;
+    cu = new JarFileResources(new JarFile[] {gwtDevJar}, gwtIncludedPaths,
+        new HashSet<String>(), logger);
+    resources.addAll(cu.getResources());
+    return resources;
   }
 
   /*
diff --git a/tools/api-checker/src/com/google/gwt/tools/apichecker/ApiContainer.java b/tools/api-checker/src/com/google/gwt/tools/apichecker/ApiContainer.java
index 9c27d22..c7fc6d4 100644
--- a/tools/api-checker/src/com/google/gwt/tools/apichecker/ApiContainer.java
+++ b/tools/api-checker/src/com/google/gwt/tools/apichecker/ApiContainer.java
@@ -21,15 +21,14 @@
 import com.google.gwt.core.ext.typeinfo.JClassType;
 import com.google.gwt.core.ext.typeinfo.JConstructor;
 import com.google.gwt.core.ext.typeinfo.JPackage;
-import com.google.gwt.core.ext.typeinfo.NotFoundException;
 import com.google.gwt.core.ext.typeinfo.TypeOracle;
 import com.google.gwt.dev.javac.CompilationUnit;
 import com.google.gwt.dev.javac.CompilationUnitInvalidator;
 import com.google.gwt.dev.javac.JdtCompiler;
 import com.google.gwt.dev.javac.TypeOracleMediator;
+import com.google.gwt.dev.javac.impl.SourceFileCompilationUnit;
+import com.google.gwt.dev.resource.Resource;
 
-import java.io.FileNotFoundException;
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -58,29 +57,20 @@
    * A public constructor used for programmatic invocation and testing.
    * 
    * @param name Api name
-   * @param units a set of CompilationUnits
+   * @param resources a set of Resources
    * @param excludedPackages a set of excludedPackages
    * @param logger TreeLogger for logging messages
    * @throws IllegalArgumentException if one of the arguments is illegal
    * @throws UnableToCompleteException if there is a TypeOracle exception
    */
-  ApiContainer(String name, Set<CompilationUnit> units,
+  ApiContainer(String name, Set<Resource> resources,
       Set<String> excludedPackages, TreeLogger logger)
       throws UnableToCompleteException {
     this.name = name;
     this.logger = logger;
-    logger.log(TreeLogger.INFO, "name = " + name + ", units.size = " + units.size(), null);
-    try {
-      this.typeOracle = getTypeOracleFromCompilationUnits(units);
-    } catch (FileNotFoundException e2) {
-      System.err.println("Do you have a reference version of the API checked out?");
-      throw new IllegalArgumentException(e2);
-    } catch (IOException e3) {
-      throw new IllegalArgumentException(e3);
-    } catch (NotFoundException e4) {
-      logger.log(TreeLogger.ERROR, "logged a NotFoundException", e4);
-      throw new UnableToCompleteException();
-    }
+    logger.log(TreeLogger.INFO, "name = " + name + ", builders.size = "
+        + resources.size(), null);
+    this.typeOracle = createTypeOracle(resources);
     this.excludedPackages = excludedPackages;
     initializeApiPackages();
   }
@@ -191,9 +181,12 @@
     return false;
   }
 
-  private TypeOracle getTypeOracleFromCompilationUnits(
-      Set<CompilationUnit> units) throws NotFoundException, IOException,
-      UnableToCompleteException {
+  private TypeOracle createTypeOracle(Set<Resource> resources)
+      throws UnableToCompleteException {
+    Set<CompilationUnit> units = new HashSet<CompilationUnit>();
+    for (Resource resource : resources) {
+      units.add(new SourceFileCompilationUnit(resource));
+    }
     JdtCompiler.compile(units);
     if (CompilationUnitInvalidator.invalidateUnitsWithErrors(logger, units)) {
       logger.log(TreeLogger.ERROR, "Unable to build typeOracle for "
diff --git a/tools/api-checker/test/com/google/gwt/tools/apichecker/ApiCompatibilityTest.java b/tools/api-checker/test/com/google/gwt/tools/apichecker/ApiCompatibilityTest.java
index 5a2357e..4ca625c 100644
--- a/tools/api-checker/test/com/google/gwt/tools/apichecker/ApiCompatibilityTest.java
+++ b/tools/api-checker/test/com/google/gwt/tools/apichecker/ApiCompatibilityTest.java
@@ -18,10 +18,10 @@
 import com.google.gwt.core.ext.TreeLogger;
 import com.google.gwt.core.ext.UnableToCompleteException;
 import com.google.gwt.core.ext.typeinfo.NotFoundException;
-import com.google.gwt.dev.javac.CompilationUnit;
+import com.google.gwt.dev.javac.impl.StaticJavaResource;
+import com.google.gwt.dev.resource.Resource;
 import com.google.gwt.dev.util.log.AbstractTreeLogger;
 import com.google.gwt.dev.util.log.PrintWriterTreeLogger;
-import com.google.gwt.tools.apichecker.ApiCompatibilityChecker.StaticCompilationUnit;
 
 import junit.framework.TestCase;
 
@@ -48,20 +48,18 @@
   // These cups are slightly different from the cups in ApiContainerTest
   private static final boolean DEBUG = false;
 
-  private static StaticCompilationUnit[] getScuArray() {
-    return new StaticCompilationUnit[] {
-        new StaticCompilationUnit("test.apicontainer.ApiClass",
-            getSourceForApiClass()),
-        new StaticCompilationUnit("test.apicontainer.NonApiClass",
+  private static StaticJavaResource[] getScuArray() {
+    return new StaticJavaResource[] {
+        new StaticJavaResource("test.apicontainer.ApiClass", getSourceForApiClass()),
+        new StaticJavaResource("test.apicontainer.NonApiClass",
             getSourceForNonApiClass()),
-        new StaticCompilationUnit("test.nonapipackage.TestClass",
+        new StaticJavaResource("test.nonapipackage.TestClass",
             getSourceForTestClass()),
-        new StaticCompilationUnit("java.lang.Object", getSourceForObject()),
-        new StaticCompilationUnit("java.lang.Throwable",
-            getSourceForThrowable()),
-        new StaticCompilationUnit("test.apicontainer.OneMoreApiClass",
+        new StaticJavaResource("java.lang.Object", getSourceForObject()),
+        new StaticJavaResource("java.lang.Throwable", getSourceForThrowable()),
+        new StaticJavaResource("test.apicontainer.OneMoreApiClass",
             getSourceForOneMoreApiClass()),
-        new StaticCompilationUnit("java.lang.RuntimeException",
+        new StaticJavaResource("java.lang.RuntimeException",
             getSourceForRuntimeException()),};
   }
 
@@ -151,13 +149,13 @@
     AbstractTreeLogger logger = new PrintWriterTreeLogger();
     logger.setMaxDetail(TreeLogger.ERROR);
 
-    api1 = new ApiContainer("Api1", new HashSet<CompilationUnit>(
+    api1 = new ApiContainer("Api1", new HashSet<Resource>(
         Arrays.asList(ApiContainerTest.getScuArray())), new HashSet<String>(),
         logger);
-    apiSameAs1 = new ApiContainer("ApiSameAs1", new HashSet<CompilationUnit>(
+    apiSameAs1 = new ApiContainer("ApiSameAs1", new HashSet<Resource>(
         Arrays.asList(ApiContainerTest.getScuArray())), new HashSet<String>(),
         logger);
-    api2 = new ApiContainer("Api2", new HashSet<CompilationUnit>(
+    api2 = new ApiContainer("Api2", new HashSet<Resource>(
         Arrays.asList(getScuArray())), new HashSet<String>(), logger);
   }
 
diff --git a/tools/api-checker/test/com/google/gwt/tools/apichecker/ApiCompatibilityUnitTest.java b/tools/api-checker/test/com/google/gwt/tools/apichecker/ApiCompatibilityUnitTest.java
index c9166d7..9e628d2 100644
--- a/tools/api-checker/test/com/google/gwt/tools/apichecker/ApiCompatibilityUnitTest.java
+++ b/tools/api-checker/test/com/google/gwt/tools/apichecker/ApiCompatibilityUnitTest.java
@@ -18,10 +18,10 @@
 import com.google.gwt.core.ext.TreeLogger;
 import com.google.gwt.core.ext.UnableToCompleteException;
 import com.google.gwt.core.ext.typeinfo.NotFoundException;
-import com.google.gwt.dev.javac.CompilationUnit;
+import com.google.gwt.dev.javac.impl.StaticJavaResource;
+import com.google.gwt.dev.resource.Resource;
 import com.google.gwt.dev.util.log.AbstractTreeLogger;
 import com.google.gwt.dev.util.log.PrintWriterTreeLogger;
-import com.google.gwt.tools.apichecker.ApiCompatibilityChecker.StaticCompilationUnit;
 
 import junit.framework.TestCase;
 
@@ -265,15 +265,14 @@
     AbstractTreeLogger logger = new PrintWriterTreeLogger();
     logger.setMaxDetail(TreeLogger.ERROR);
 
-    Set<CompilationUnit> set1 = new HashSet<CompilationUnit>();
-    for (Map.Entry<String, String> entry
-        : existingTypesToSourcesMap.entrySet()) {
-      set1.add(new StaticCompilationUnit(entry.getKey(), entry.getValue()));
+    Set<Resource> set1 = new HashSet<Resource>();
+    for (Map.Entry<String, String> entry : existingTypesToSourcesMap.entrySet()) {
+      set1.add(new StaticJavaResource(entry.getKey(), entry.getValue()));
     }
     Set<String> emptyList = Collections.emptySet();
-    Set<CompilationUnit> set2 = new HashSet<CompilationUnit>();
+    Set<Resource> set2 = new HashSet<Resource>();
     for (String type : existingTypesToSourcesMap.keySet()) {
-      set2.add(new StaticCompilationUnit(type, newTypesToSourcesMap.get(type)));
+      set2.add(new StaticJavaResource(type, newTypesToSourcesMap.get(type)));
     }
 
     ApiContainer existingApi = new ApiContainer("existingApi", set1, emptyList,
diff --git a/tools/api-checker/test/com/google/gwt/tools/apichecker/ApiContainerTest.java b/tools/api-checker/test/com/google/gwt/tools/apichecker/ApiContainerTest.java
index f21a63b..a73c13d 100644
--- a/tools/api-checker/test/com/google/gwt/tools/apichecker/ApiContainerTest.java
+++ b/tools/api-checker/test/com/google/gwt/tools/apichecker/ApiContainerTest.java
@@ -17,10 +17,10 @@
 
 import com.google.gwt.core.ext.UnableToCompleteException;
 import com.google.gwt.core.ext.typeinfo.JAbstractMethod;
-import com.google.gwt.dev.javac.CompilationUnit;
+import com.google.gwt.dev.javac.impl.StaticJavaResource;
+import com.google.gwt.dev.resource.Resource;
 import com.google.gwt.dev.util.log.AbstractTreeLogger;
 import com.google.gwt.dev.util.log.PrintWriterTreeLogger;
-import com.google.gwt.tools.apichecker.ApiCompatibilityChecker.StaticCompilationUnit;
 
 import junit.framework.TestCase;
 
@@ -61,18 +61,18 @@
     }
   }
 
-  public static StaticCompilationUnit[] getScuArray() {
-    return new StaticCompilationUnit[] {
-        new StaticCompilationUnit("test.apicontainer.ApiClass",
+  public static StaticJavaResource[] getScuArray() {
+    return new StaticJavaResource[] {
+        new StaticJavaResource("test.apicontainer.ApiClass",
             getSourceForApiClass()),
-        new StaticCompilationUnit("test.apicontainer.NonApiClass",
+        new StaticJavaResource("test.apicontainer.NonApiClass",
             getSourceForNonApiClass()),
-        new StaticCompilationUnit("test.nonapipackage.TestClass",
+        new StaticJavaResource("test.nonapipackage.TestClass",
             getSourceForTestClass()),
-        new StaticCompilationUnit("java.lang.Object", getSourceForObject()),
-        new StaticCompilationUnit("test.apicontainer.OneMoreApiClass",
+        new StaticJavaResource("java.lang.Object", getSourceForObject()),
+        new StaticJavaResource("test.apicontainer.OneMoreApiClass",
             getSourceForOneMoreApiClass()),
-        new StaticCompilationUnit("java.newpackage.Test", getSourceForTest()),};
+        new StaticJavaResource("java.newpackage.Test", getSourceForTest()),};
   }
 
   private static JAbstractMethod getMethodByName(String name, ApiClass apiClass) {
@@ -162,9 +162,8 @@
   public void setUp() throws UnableToCompleteException {
     logger.setMaxDetail(com.google.gwt.core.ext.TreeLogger.ERROR);
 
-    apiCheck = new ApiContainer("ApiContainerTest",
-        new HashSet<CompilationUnit>(Arrays.asList(getScuArray())),
-        new HashSet<String>(), logger);
+    apiCheck = new ApiContainer("ApiContainerTest", new HashSet<Resource>(
+        Arrays.asList(getScuArray())), new HashSet<String>(), logger);
   }
 
   /*
@@ -181,10 +180,9 @@
     sb.append("class Temp {\n");
     sb.append("}");
 
-    ApiContainer apiCheckLoop = new ApiContainer(
-        "ApiClassTest",
-        new HashSet<CompilationUnit>(
-            Arrays.asList(new StaticCompilationUnit[] {new StaticCompilationUnit(
+    ApiContainer apiCheckLoop = new ApiContainer("ApiClassTest",
+        new HashSet<Resource>(
+            Arrays.asList(new StaticJavaResource[] {new StaticJavaResource(
                 "java.lang.Object", sb.toString())})), new HashSet<String>(),
         logger);
     ApiPackage javaLangPackage = apiCheckLoop.getApiPackage("java.lang");
diff --git a/user/test/com/google/gwt/uibinder/elementparsers/ElementParserTester.java b/user/test/com/google/gwt/uibinder/elementparsers/ElementParserTester.java
index fc6e5b2..441fab6 100644
--- a/user/test/com/google/gwt/uibinder/elementparsers/ElementParserTester.java
+++ b/user/test/com/google/gwt/uibinder/elementparsers/ElementParserTester.java
@@ -20,9 +20,9 @@
 import com.google.gwt.core.ext.typeinfo.JClassType;
 import com.google.gwt.core.ext.typeinfo.TypeOracle;
 import com.google.gwt.dev.javac.CompilationState;
+import com.google.gwt.dev.javac.CompilationStateBuilder;
 import com.google.gwt.dev.javac.impl.MockJavaResource;
-import com.google.gwt.dev.javac.impl.MockResourceOracle;
-import com.google.gwt.dev.util.collect.Lists;
+import com.google.gwt.dev.resource.Resource;
 import com.google.gwt.uibinder.attributeparsers.AttributeParsers;
 import com.google.gwt.uibinder.rebind.FieldManager;
 import com.google.gwt.uibinder.rebind.FieldWriter;
@@ -38,7 +38,7 @@
 import org.xml.sax.SAXException;
 
 import java.io.IOException;
-import java.util.List;
+import java.util.Set;
 
 class ElementParserTester {
    static final MockJavaResource BINDER_OWNER_JAVA = new MockJavaResource(
@@ -74,8 +74,8 @@
     this.parser = parser;
     String templatePath = "TemplatePath.ui.xml";
     String implName = "ImplClass";
-    MockResourceOracle resources = new MockResourceOracle(getUiResources());
-    CompilationState state = new CompilationState(TreeLogger.NULL, resources);
+    CompilationState state = CompilationStateBuilder.buildFrom(TreeLogger.NULL,
+        getUiResources());
     types = state.getTypeOracle();
 
     elemProvider = new XMLElementProviderImpl(new AttributeParsers(), null,
@@ -113,9 +113,9 @@
     return elem;
   }
 
-  private MockJavaResource[] getUiResources() {
-    List<MockJavaResource> rtn = Lists.create(UiJavaResources.getUiResources());
+  private Set<Resource> getUiResources() {
+    Set<Resource> rtn = UiJavaResources.getUiResources();
     rtn.add(BINDER_OWNER_JAVA);
-    return rtn.toArray(new MockJavaResource[rtn.size()]);
+    return rtn;
   }
 }
\ No newline at end of file
diff --git a/user/test/com/google/gwt/uibinder/elementparsers/UiJavaResources.java b/user/test/com/google/gwt/uibinder/elementparsers/UiJavaResources.java
index 67aa21f..250c5a5 100644
--- a/user/test/com/google/gwt/uibinder/elementparsers/UiJavaResources.java
+++ b/user/test/com/google/gwt/uibinder/elementparsers/UiJavaResources.java
@@ -17,9 +17,11 @@
 
 import com.google.gwt.dev.javac.impl.JavaResourceBase;
 import com.google.gwt.dev.javac.impl.MockJavaResource;
-import com.google.gwt.dev.util.collect.Lists;
+import com.google.gwt.dev.resource.Resource;
+import com.google.gwt.dev.util.collect.HashSet;
 
-import java.util.List;
+import java.util.Arrays;
+import java.util.Set;
 
 /**
  * A pared down, very low fidelity set of GWT widget Java source files for code
@@ -110,9 +112,9 @@
    * @return a pale reflection of com.google.gwt.user.ui, plus
    *         {@link JavaResourceBase#getStandardResources}
    */
-  public static MockJavaResource[] getUiResources() {
-    MockJavaResource[] base = JavaResourceBase.getStandardResources();
-    List<MockJavaResource> rtn = Lists.create(base);
+  public static Set<Resource> getUiResources() {
+    Set<Resource> rtn = new HashSet<Resource>(
+        Arrays.asList(JavaResourceBase.getStandardResources()));
     rtn.add(DIALOG_BOX);
     rtn.add(DOCK_LAYOUT_PANEL);
     rtn.add(LABEL);
@@ -120,6 +122,6 @@
     rtn.add(STYLE);
     rtn.add(UI_BINDER);
     rtn.add(WIDGET);
-    return rtn.toArray(new MockJavaResource[rtn.size()]);
+    return rtn;
   }
-}
\ No newline at end of file
+}
diff --git a/user/test/com/google/gwt/uibinder/rebind/XMLElementTest.java b/user/test/com/google/gwt/uibinder/rebind/XMLElementTest.java
index 3acdf5a..09a18a1 100644
--- a/user/test/com/google/gwt/uibinder/rebind/XMLElementTest.java
+++ b/user/test/com/google/gwt/uibinder/rebind/XMLElementTest.java
@@ -19,6 +19,7 @@
 import com.google.gwt.core.ext.UnableToCompleteException;
 import com.google.gwt.core.ext.typeinfo.TypeOracle;
 import com.google.gwt.dev.javac.CompilationState;
+import com.google.gwt.dev.javac.CompilationStateBuilder;
 import com.google.gwt.dev.javac.impl.JavaResourceBase;
 import com.google.gwt.dev.javac.impl.MockResourceOracle;
 import com.google.gwt.uibinder.attributeparsers.AttributeParsers;
@@ -54,8 +55,8 @@
     super.setUp();
     MockResourceOracle resourceOracle = new MockResourceOracle(
         JavaResourceBase.getStandardResources());
-    CompilationState state = new CompilationState(TreeLogger.NULL,
-        resourceOracle);
+    CompilationState state = CompilationStateBuilder.buildFrom(TreeLogger.NULL,
+        resourceOracle.getResources()); 
     oracle = state.getTypeOracle();
     logger = new MockMortalLogger();
     elemProvider = new XMLElementProviderImpl(new AttributeParsers(), null,
diff --git a/user/test/com/google/gwt/user/rebind/rpc/SerializableTypeOracleBuilderTest.java b/user/test/com/google/gwt/user/rebind/rpc/SerializableTypeOracleBuilderTest.java
index 1e187f5..43fd82a 100644
--- a/user/test/com/google/gwt/user/rebind/rpc/SerializableTypeOracleBuilderTest.java
+++ b/user/test/com/google/gwt/user/rebind/rpc/SerializableTypeOracleBuilderTest.java
@@ -33,11 +33,10 @@
 import com.google.gwt.dev.cfg.ModuleDef;
 import com.google.gwt.dev.cfg.ModuleDefLoader;
 import com.google.gwt.dev.cfg.StaticPropertyOracle;
-import com.google.gwt.dev.javac.CompilationUnit;
-import com.google.gwt.dev.javac.MockCompilationUnit;
 import com.google.gwt.dev.javac.TypeOracleTestingUtils;
 import com.google.gwt.dev.javac.impl.JavaResourceBase;
-import com.google.gwt.dev.javac.impl.SourceFileCompilationUnit;
+import com.google.gwt.dev.javac.impl.MockJavaResource;
+import com.google.gwt.dev.javac.impl.StaticJavaResource;
 import com.google.gwt.dev.resource.Resource;
 import com.google.gwt.dev.util.log.PrintWriterTreeLogger;
 import com.google.gwt.user.rebind.rpc.testcases.client.AbstractSerializableTypes;
@@ -108,30 +107,30 @@
 
   private static TypeOracle sTypeOracle;
 
-  private static void addGwtTransient(Set<CompilationUnit> units) {
+  private static void addGwtTransient(Set<Resource> resources) {
     StringBuffer code = new StringBuffer();
     code.append("package com.google.gwt.user.client.rpc;\n");
     code.append("public @interface GwtTransient { }\n");
-    units.add(createMockCompilationUnit(
+    resources.add(new StaticJavaResource(
         "com.google.gwt.user.client.rpc.GwtTransient", code));
   }
 
-  private static void addICRSE(Set<CompilationUnit> units) {
+  private static void addICRSE(Set<Resource> resources) {
     StringBuffer code = new StringBuffer();
     code.append("package com.google.gwt.user.client.rpc;\n");
     code.append("public class IncompatibleRemoteServiceException extends Throwable {\n");
     code.append("}\n");
-    units.add(createMockCompilationUnit(
+    resources.add(new StaticJavaResource(
         "com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException",
         code));
   }
 
-  private static void addStandardClasses(Set<CompilationUnit> units) {
-    for (Resource resource : JavaResourceBase.getStandardResources()) {
-      units.add(new SourceFileCompilationUnit(resource));
+  private static void addStandardClasses(Set<Resource> resources) {
+    for (MockJavaResource resource : JavaResourceBase.getStandardResources()) {
+      resources.add(resource);
     }
-    addGwtTransient(units);
-    addICRSE(units);
+    addGwtTransient(resources);
+    addICRSE(resources);
   }
 
   private static void assertFieldSerializable(SerializableTypeOracle so,
@@ -184,11 +183,6 @@
     return logger;
   }
 
-  private static CompilationUnit createMockCompilationUnit(String qname,
-      CharSequence code) {
-    return new MockCompilationUnit(qname, code.toString());
-  }
-
   private static SerializableTypeOracleBuilder createSerializableTypeOracleBuilder(
       TreeLogger logger, TypeOracle to) throws UnableToCompleteException {
     // Make an empty property oracle.
@@ -218,7 +212,7 @@
           new String[] {
               "com.google.gwt.user.rebind.rpc.testcases.RebindRPCTestCases",
               "com.google.gwt.junit.JUnit"}, true);
-      sTypeOracle = moduleDef.getTypeOracle(logger);
+      sTypeOracle = moduleDef.getCompilationState(logger).getTypeOracle();
     }
     return sTypeOracle;
   }
@@ -272,22 +266,22 @@
    */
   public void disabledTestMaybeExposedParameter()
       throws UnableToCompleteException, NotFoundException {
-    Set<CompilationUnit> units = new HashSet<CompilationUnit>();
-    addStandardClasses(units);
+    Set<Resource> resources = new HashSet<Resource>();
+    addStandardClasses(resources);
 
     {
       StringBuilder code = new StringBuilder();
       code.append("import java.io.Serializable;\n");
       code.append("public abstract class List<T> implements Serializable {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("List", code));
+      resources.add(new StaticJavaResource("List", code));
     }
 
     {
       StringBuilder code = new StringBuilder();
       code.append("public class EmptyList<T> extends List<T> {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("EmptyList", code));
+      resources.add(new StaticJavaResource("EmptyList", code));
     }
 
     {
@@ -296,18 +290,18 @@
       code.append("  T head;\n");
       code.append("  LinkedList<T> next;\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("LinkedList", code));
+      resources.add(new StaticJavaResource("LinkedList", code));
     }
 
     {
       StringBuilder code = new StringBuilder();
       code.append("public class CantSerialize {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("CantSerialize", code));
+      resources.add(new StaticJavaResource("CantSerialize", code));
     }
 
     TreeLogger logger = createLogger();
-    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, units);
+    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, resources);
 
     JGenericType list = to.getType("List").isGenericType();
     JGenericType emptyList = to.getType("EmptyList").isGenericType();
@@ -333,15 +327,15 @@
    */
   public void testAbstractFieldSerializableRootType()
       throws UnableToCompleteException, NotFoundException {
-    Set<CompilationUnit> units = new HashSet<CompilationUnit>();
-    addStandardClasses(units);
+    Set<Resource> resources = new HashSet<Resource>();
+    addStandardClasses(resources);
 
     {
       StringBuilder code = new StringBuilder();
       code.append("import java.io.Serializable;\n");
       code.append("public abstract class A implements Serializable {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("A", code));
+      resources.add(new StaticJavaResource("A", code));
     }
 
     {
@@ -349,7 +343,7 @@
       code.append("import java.io.Serializable;\n");
       code.append("public abstract class B extends A {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("B", code));
+      resources.add(new StaticJavaResource("B", code));
     }
 
     {
@@ -357,11 +351,11 @@
       code.append("import java.io.Serializable;\n");
       code.append("public class C extends B {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("C", code));
+      resources.add(new StaticJavaResource("C", code));
     }
 
     TreeLogger logger = createLogger();
-    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, units);
+    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, resources);
 
     JClassType a = to.getType("A");
     JClassType b = to.getType("B");
@@ -384,8 +378,8 @@
    */
   public void testAccessLevelsInJavaPackage() throws UnableToCompleteException,
       NotFoundException {
-    Set<CompilationUnit> units = new HashSet<CompilationUnit>();
-    addStandardClasses(units);
+    Set<Resource> resources = new HashSet<Resource>();
+    addStandardClasses(resources);
 
     {
       StringBuilder code = new StringBuilder();
@@ -393,7 +387,7 @@
       code.append("import java.io.Serializable;\n");
       code.append("public class A implements Serializable {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("java.A", code));
+      resources.add(new StaticJavaResource("java.A", code));
     }
 
     {
@@ -402,7 +396,7 @@
       code.append("import java.io.Serializable;\n");
       code.append("class B extends A {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("java.B", code));
+      resources.add(new StaticJavaResource("java.B", code));
     }
 
     {
@@ -411,11 +405,11 @@
       code.append("import java.io.Serializable;\n");
       code.append("public class C extends A {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("java.C", code));
+      resources.add(new StaticJavaResource("java.C", code));
     }
 
     TreeLogger logger = createLogger();
-    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, units);
+    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, resources);
 
     JClassType a = to.getType("java.A");
     JArrayType arrayOfA = to.getArrayType(a);
@@ -436,8 +430,8 @@
    */
   public void testArrayOfParameterizedTypes() throws UnableToCompleteException,
       NotFoundException {
-    Set<CompilationUnit> units = new HashSet<CompilationUnit>();
-    addStandardClasses(units);
+    Set<Resource> resources = new HashSet<Resource>();
+    addStandardClasses(resources);
 
     {
       // A<T> exposes its param
@@ -446,7 +440,7 @@
       code.append("public class A<T> implements Serializable {\n");
       code.append("  T t;\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("A", code));
+      resources.add(new StaticJavaResource("A", code));
     }
 
     {
@@ -455,7 +449,7 @@
       code.append("public class AList<T> implements Serializable {\n");
       code.append("  A<T>[] as;\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("AList", code));
+      resources.add(new StaticJavaResource("AList", code));
     }
 
     {
@@ -464,7 +458,7 @@
       code.append("import java.io.Serializable;\n");
       code.append("public class B<T> implements Serializable {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("B", code));
+      resources.add(new StaticJavaResource("B", code));
     }
 
     {
@@ -473,7 +467,7 @@
       code.append("public class BList<T> implements Serializable {\n");
       code.append("  B<T>[] bs;\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("BList", code));
+      resources.add(new StaticJavaResource("BList", code));
     }
 
     {
@@ -482,7 +476,7 @@
       code.append("import java.io.Serializable;\n");
       code.append("public class Ser1 implements Serializable {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("Ser1", code));
+      resources.add(new StaticJavaResource("Ser1", code));
     }
 
     {
@@ -491,7 +485,7 @@
       code.append("import java.io.Serializable;\n");
       code.append("public class Ser2 implements Serializable {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("Ser2", code));
+      resources.add(new StaticJavaResource("Ser2", code));
     }
 
     {
@@ -501,11 +495,11 @@
       code.append("  AList<Ser1> alist;\n");
       code.append("  BList<Ser2> blist;\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("Root", code));
+      resources.add(new StaticJavaResource("Root", code));
     }
 
     TreeLogger logger = createLogger();
-    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, units);
+    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, resources);
 
     JGenericType a = to.getType("A").isGenericType();
     JGenericType b = to.getType("B").isGenericType();
@@ -547,15 +541,15 @@
    */
   public void testArrayOfTypeParameter() throws UnableToCompleteException,
       NotFoundException {
-    Set<CompilationUnit> units = new HashSet<CompilationUnit>();
-    addStandardClasses(units);
+    Set<Resource> resources = new HashSet<Resource>();
+    addStandardClasses(resources);
 
     {
       StringBuilder code = new StringBuilder();
       code.append("import java.io.Serializable;\n");
       code.append("public class A<T> implements Serializable {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("A", code));
+      resources.add(new StaticJavaResource("A", code));
     }
 
     {
@@ -564,7 +558,7 @@
       code.append("public class B<T> extends A<T> implements Serializable {\n");
       code.append("  T[][] t;\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("B", code));
+      resources.add(new StaticJavaResource("B", code));
     }
 
     {
@@ -574,7 +568,7 @@
       code.append("  A<T[]> a1;\n");
       code.append("  A<Ser> a2;\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("C", code));
+      resources.add(new StaticJavaResource("C", code));
     }
 
     {
@@ -582,11 +576,11 @@
       code.append("import java.io.Serializable;\n");
       code.append("public class Ser implements Serializable {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("Ser", code));
+      resources.add(new StaticJavaResource("Ser", code));
     }
 
     TreeLogger logger = createLogger();
-    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, units);
+    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, resources);
 
     JGenericType a = to.getType("A").isGenericType();
     JGenericType b = to.getType("B").isGenericType();
@@ -634,14 +628,14 @@
    */
   public void testClassQualifiesForSerialization()
       throws UnableToCompleteException, NotFoundException {
-    Set<CompilationUnit> units = new HashSet<CompilationUnit>();
-    addStandardClasses(units);
+    Set<Resource> resources = new HashSet<Resource>();
+    addStandardClasses(resources);
 
     {
       StringBuilder code = new StringBuilder();
       code.append("public class NotSerializable {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("NotSerializable", code));
+      resources.add(new StaticJavaResource("NotSerializable", code));
     }
 
     {
@@ -651,7 +645,7 @@
       code.append("  interface IFoo extends Serializable {};\n");
       code.append("  IFoo createFoo() { return new IFoo(){};}\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("AutoSerializable", code));
+      resources.add(new StaticJavaResource("AutoSerializable", code));
     }
 
     {
@@ -661,7 +655,7 @@
       code.append("  static class StaticNested implements Serializable {};\n");
       code.append("  class NonStaticNested implements Serializable {};\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("OuterClass", code));
+      resources.add(new StaticJavaResource("OuterClass", code));
     }
 
     {
@@ -669,7 +663,7 @@
       code.append("import java.io.Serializable;\n");
       code.append("public abstract class AbstractSerializableClass implements Serializable {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("AbstractSerializableClass", code));
+      resources.add(new StaticJavaResource("AbstractSerializableClass", code));
     }
 
     {
@@ -678,8 +672,8 @@
       code.append("public class NonDefaultInstantiableSerializable implements Serializable {\n");
       code.append("  NonDefaultInstantiableSerializable(int i) {}\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("NonDefaultInstantiableSerializable",
-          code));
+      resources.add(new StaticJavaResource(
+          "NonDefaultInstantiableSerializable", code));
     }
 
     {
@@ -695,7 +689,7 @@
       code.append("    }\n");
       code.append("  }\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("PublicOuterClass", code));
+      resources.add(new StaticJavaResource("PublicOuterClass", code));
     }
 
     {
@@ -715,7 +709,7 @@
       code.append("  };\n");
       code.append("  public abstract String value();\n");
       code.append("};\n");
-      units.add(createMockCompilationUnit("EnumWithSubclasses", code));
+      resources.add(new StaticJavaResource("EnumWithSubclasses", code));
     }
 
     {
@@ -727,11 +721,11 @@
       code.append("    this.value = value;\n");
       code.append("  }\n");
       code.append("};\n");
-      units.add(createMockCompilationUnit("EnumWithNonDefaultCtors", code));
+      resources.add(new StaticJavaResource("EnumWithNonDefaultCtors", code));
     }
 
     TreeLogger logger = createLogger();
-    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, units);
+    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, resources);
     SerializableTypeOracleBuilder sob = createSerializableTypeOracleBuilder(
         logger, to);
 
@@ -843,8 +837,8 @@
    */
   public void testConcreteClassesConstrainATypeParameter()
       throws NotFoundException, UnableToCompleteException {
-    Set<CompilationUnit> units = new HashSet<CompilationUnit>();
-    addStandardClasses(units);
+    Set<Resource> resources = new HashSet<Resource>();
+    addStandardClasses(resources);
 
     {
       StringBuilder code = new StringBuilder();
@@ -852,7 +846,7 @@
       code.append("public abstract class Holder<T extends Serializable> implements Serializable {\n");
       code.append("  T x;\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("Holder", code));
+      resources.add(new StaticJavaResource("Holder", code));
     }
 
     {
@@ -860,7 +854,7 @@
       code.append("import java.io.Serializable;\n");
       code.append("public class StringHolder extends Holder<String> implements Serializable {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("StringHolder", code));
+      resources.add(new StaticJavaResource("StringHolder", code));
     }
 
     {
@@ -868,7 +862,7 @@
       code.append("import java.io.Serializable;\n");
       code.append("public class DateHolder extends Holder<Date> implements Serializable {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("DateHolder", code));
+      resources.add(new StaticJavaResource("DateHolder", code));
     }
 
     {
@@ -876,7 +870,7 @@
       code.append("import java.io.Serializable;\n");
       code.append("public class Date implements Serializable {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("Date", code));
+      resources.add(new StaticJavaResource("Date", code));
     }
 
     {
@@ -884,11 +878,11 @@
       code.append("import java.io.Serializable;\n");
       code.append("public class UnrelatedClass implements Serializable {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("UnrelatedClass", code));
+      resources.add(new StaticJavaResource("UnrelatedClass", code));
     }
 
     TreeLogger logger = createLogger();
-    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, units);
+    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, resources);
 
     JGenericType holder = to.getType("Holder").isGenericType();
     JClassType stringHolder = to.getType("StringHolder");
@@ -919,15 +913,15 @@
    */
   public void testCovariantArrays() throws UnableToCompleteException,
       NotFoundException {
-    Set<CompilationUnit> units = new HashSet<CompilationUnit>();
-    addStandardClasses(units);
+    Set<Resource> resources = new HashSet<Resource>();
+    addStandardClasses(resources);
 
     {
       StringBuilder code = new StringBuilder();
       code.append("import java.io.Serializable;\n");
       code.append("public class Sup implements Serializable {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("Sup", code));
+      resources.add(new StaticJavaResource("Sup", code));
     }
 
     {
@@ -935,11 +929,11 @@
       code.append("import java.io.Serializable;\n");
       code.append("public class Sub extends Sup {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("Sub", code));
+      resources.add(new StaticJavaResource("Sub", code));
     }
 
     TreeLogger logger = createLogger();
-    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, units);
+    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, resources);
 
     JClassType sup = to.getType("Sup");
     JClassType sub = to.getType("Sub");
@@ -979,8 +973,8 @@
    */
   public void testExtensionFromRaw1() throws UnableToCompleteException,
       NotFoundException {
-    Set<CompilationUnit> units = new HashSet<CompilationUnit>();
-    addStandardClasses(units);
+    Set<Resource> resources = new HashSet<Resource>();
+    addStandardClasses(resources);
 
     {
       StringBuilder code = new StringBuilder();
@@ -988,7 +982,7 @@
       code.append("public class HashSet<T extends SerClass> implements Serializable {\n");
       code.append("  T[] x;\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("HashSet", code));
+      resources.add(new StaticJavaResource("HashSet", code));
     }
 
     {
@@ -996,7 +990,7 @@
       code.append("import java.io.Serializable;\n");
       code.append("public class NameSet extends HashSet implements Serializable {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("NameSet", code));
+      resources.add(new StaticJavaResource("NameSet", code));
     }
 
     {
@@ -1004,7 +998,7 @@
       code.append("import java.io.Serializable;\n");
       code.append("public class SerClass implements Serializable {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("SerClass", code));
+      resources.add(new StaticJavaResource("SerClass", code));
     }
 
     {
@@ -1012,11 +1006,11 @@
       code.append("import java.io.Serializable;\n");
       code.append("public class SerClassSub extends SerClass {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("SerClassSub", code));
+      resources.add(new StaticJavaResource("SerClassSub", code));
     }
 
     TreeLogger logger = createLogger();
-    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, units);
+    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, resources);
 
     JGenericType hashSet = to.getType("HashSet").isGenericType();
     JClassType nameSet = to.getType("NameSet");
@@ -1052,8 +1046,8 @@
    */
   public void testExtensionFromRaw2() throws UnableToCompleteException,
       NotFoundException {
-    Set<CompilationUnit> units = new HashSet<CompilationUnit>();
-    addStandardClasses(units);
+    Set<Resource> resources = new HashSet<Resource>();
+    addStandardClasses(resources);
 
     {
       StringBuilder code = new StringBuilder();
@@ -1061,7 +1055,7 @@
       code.append("public class HashSet<T extends Serializable> implements Serializable {\n");
       code.append("  T[] x;\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("HashSet", code));
+      resources.add(new StaticJavaResource("HashSet", code));
     }
 
     {
@@ -1070,7 +1064,7 @@
       code.append("public class NameSet<T extends SerClass> extends HashSet implements Serializable {\n");
       code.append("  T exposed;\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("NameSet", code));
+      resources.add(new StaticJavaResource("NameSet", code));
     }
 
     {
@@ -1078,7 +1072,7 @@
       code.append("import java.io.Serializable;\n");
       code.append("public class SerClass implements Serializable {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("SerClass", code));
+      resources.add(new StaticJavaResource("SerClass", code));
     }
 
     {
@@ -1086,7 +1080,7 @@
       code.append("import java.io.Serializable;\n");
       code.append("public class SerClassSub extends SerClass {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("SerClassSub", code));
+      resources.add(new StaticJavaResource("SerClassSub", code));
     }
 
     {
@@ -1094,11 +1088,11 @@
       code.append("import java.io.Serializable;\n");
       code.append("public class UnrelatedClass implements Serializable {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("UnrelatedClass", code));
+      resources.add(new StaticJavaResource("UnrelatedClass", code));
     }
 
     TreeLogger logger = createLogger();
-    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, units);
+    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, resources);
 
     JClassType string = to.getType(String.class.getCanonicalName());
     JGenericType hashSet = to.getType("HashSet").isGenericType();
@@ -1131,8 +1125,8 @@
    */
   public void testInfiniteParameterizedTypeExpansionCase1()
       throws UnableToCompleteException, NotFoundException {
-    Set<CompilationUnit> units = new HashSet<CompilationUnit>();
-    addStandardClasses(units);
+    Set<Resource> resources = new HashSet<Resource>();
+    addStandardClasses(resources);
 
     {
       StringBuilder code = new StringBuilder();
@@ -1141,7 +1135,7 @@
       code.append("  B<T> b;\n");
       code.append("  T x;\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("A", code));
+      resources.add(new StaticJavaResource("A", code));
     }
 
     {
@@ -1150,7 +1144,7 @@
       code.append("public class B<T> extends A<T> implements Serializable {\n");
       code.append("  A<B<T>> ab;\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("B", code));
+      resources.add(new StaticJavaResource("B", code));
     }
 
     {
@@ -1158,11 +1152,11 @@
       code.append("import java.io.Serializable;\n");
       code.append("public class SerializableArgument implements Serializable {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("SerializableArgument", code));
+      resources.add(new StaticJavaResource("SerializableArgument", code));
     }
 
     TreeLogger logger = createLogger();
-    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, units);
+    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, resources);
 
     JGenericType a = to.getType("A").isGenericType();
     JGenericType b = to.getType("B").isGenericType();
@@ -1187,8 +1181,8 @@
    */
   public void testInfiniteParameterizedTypeExpansionCase2()
       throws UnableToCompleteException, NotFoundException {
-    Set<CompilationUnit> units = new HashSet<CompilationUnit>();
-    addStandardClasses(units);
+    Set<Resource> resources = new HashSet<Resource>();
+    addStandardClasses(resources);
 
     {
       StringBuilder code = new StringBuilder();
@@ -1196,7 +1190,7 @@
       code.append("public class A<T> implements Serializable {\n");
       code.append("  B<T> b;\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("A", code));
+      resources.add(new StaticJavaResource("A", code));
     }
 
     {
@@ -1205,7 +1199,7 @@
       code.append("public class B<T> extends A<T> implements Serializable {\n");
       code.append("  A<B<T>> ab;\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("B", code));
+      resources.add(new StaticJavaResource("B", code));
     }
 
     {
@@ -1213,11 +1207,11 @@
       code.append("import java.io.Serializable;\n");
       code.append("public class UnusedSerializableArgument implements Serializable {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("UnusedSerializableArgument", code));
+      resources.add(new StaticJavaResource("UnusedSerializableArgument", code));
     }
 
     TreeLogger logger = createLogger();
-    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, units);
+    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, resources);
 
     JGenericType a = to.getType("A").isGenericType();
     JGenericType b = to.getType("B").isGenericType();
@@ -1243,8 +1237,8 @@
    */
   public void testInfiniteParameterizedTypeExpansionCase3()
       throws UnableToCompleteException, NotFoundException {
-    Set<CompilationUnit> units = new HashSet<CompilationUnit>();
-    addStandardClasses(units);
+    Set<Resource> resources = new HashSet<Resource>();
+    addStandardClasses(resources);
 
     {
       StringBuilder code = new StringBuilder();
@@ -1252,7 +1246,7 @@
       code.append("public class A<T> implements Serializable {\n");
       code.append("  B<T> b;\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("A", code));
+      resources.add(new StaticJavaResource("A", code));
     }
 
     {
@@ -1261,11 +1255,11 @@
       code.append("public class B<T> extends A<T> implements Serializable {\n");
       code.append("  A<T[]> ab;\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("B", code));
+      resources.add(new StaticJavaResource("B", code));
     }
 
     TreeLogger logger = createLogger();
-    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, units);
+    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, resources);
 
     JGenericType a = to.getType("A").isGenericType();
     JGenericType b = to.getType("B").isGenericType();
@@ -1291,8 +1285,8 @@
    */
   public void testInfiniteParameterizedTypeExpansionCase4()
       throws UnableToCompleteException, NotFoundException {
-    Set<CompilationUnit> units = new HashSet<CompilationUnit>();
-    addStandardClasses(units);
+    Set<Resource> resources = new HashSet<Resource>();
+    addStandardClasses(resources);
 
     {
       StringBuilder code = new StringBuilder();
@@ -1300,7 +1294,7 @@
       code.append("public class A<T> implements Serializable {\n");
       code.append("  T t;\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("A", code));
+      resources.add(new StaticJavaResource("A", code));
     }
 
     {
@@ -1309,11 +1303,11 @@
       code.append("public class B<T> extends A<T> implements Serializable {\n");
       code.append("  A<T[]> ab;\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("B", code));
+      resources.add(new StaticJavaResource("B", code));
     }
 
     TreeLogger logger = createLogger();
-    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, units);
+    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, resources);
 
     JGenericType a = to.getType("A").isGenericType();
     JGenericType b = to.getType("B").isGenericType();
@@ -1384,89 +1378,89 @@
    */
   public void testNonOverlappingInterfaces() throws UnableToCompleteException,
       NotFoundException {
-    Set<CompilationUnit> units = new HashSet<CompilationUnit>();
-    addStandardClasses(units);
+    Set<Resource> resources = new HashSet<Resource>();
+    addStandardClasses(resources);
 
     {
       StringBuilder code = new StringBuilder();
       code.append("import java.io.Serializable;\n");
       code.append("public interface Intf1 extends Serializable {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("Intf1", code));
+      resources.add(new StaticJavaResource("Intf1", code));
     }
     {
       StringBuilder code = new StringBuilder();
       code.append("import java.io.Serializable;\n");
       code.append("public interface Intf2 extends Serializable {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("Intf2", code));
+      resources.add(new StaticJavaResource("Intf2", code));
     }
     {
       StringBuilder code = new StringBuilder();
       code.append("import java.io.Serializable;\n");
       code.append("public interface Intf3 extends Serializable {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("Intf3", code));
+      resources.add(new StaticJavaResource("Intf3", code));
     }
     {
       StringBuilder code = new StringBuilder();
       code.append("import java.io.Serializable;\n");
       code.append("public class Implements12 implements Intf1, Intf2 {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("Implements12", code));
+      resources.add(new StaticJavaResource("Implements12", code));
     }
     {
       StringBuilder code = new StringBuilder();
       code.append("import java.io.Serializable;\n");
       code.append("public class ImplementsNeither implements Serializable {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("ImplementsNeither", code));
+      resources.add(new StaticJavaResource("ImplementsNeither", code));
     }
     {
       StringBuilder code = new StringBuilder();
       code.append("import java.io.Serializable;\n");
       code.append("public interface List<T> extends Serializable  {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("List", code));
+      resources.add(new StaticJavaResource("List", code));
     }
     {
       StringBuilder code = new StringBuilder();
       code.append("import java.io.Serializable;\n");
       code.append("public class ListOfIntf1 implements List<Intf1>  {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("ListOfIntf1", code));
+      resources.add(new StaticJavaResource("ListOfIntf1", code));
     }
     {
       StringBuilder code = new StringBuilder();
       code.append("import java.io.Serializable;\n");
       code.append("public class ListOfIntf2 implements List<Intf2>  {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("ListOfIntf2", code));
+      resources.add(new StaticJavaResource("ListOfIntf2", code));
     }
     {
       StringBuilder code = new StringBuilder();
       code.append("import java.io.Serializable;\n");
       code.append("public class ListOfIntf3 implements List<Intf3>  {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("ListOfIntf3", code));
+      resources.add(new StaticJavaResource("ListOfIntf3", code));
     }
     {
       StringBuilder code = new StringBuilder();
       code.append("import java.io.Serializable;\n");
       code.append("public class ListOfImplements12 implements List<Implements12>  {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("ListOfImplements12", code));
+      resources.add(new StaticJavaResource("ListOfImplements12", code));
     }
     {
       StringBuilder code = new StringBuilder();
       code.append("import java.io.Serializable;\n");
       code.append("public class ListOfImplementsNeither implements List<ImplementsNeither>  {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("ListOfImplementsNeither", code));
+      resources.add(new StaticJavaResource("ListOfImplementsNeither", code));
     }
 
     TreeLogger logger = createLogger();
-    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, units);
+    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, resources);
 
     JClassType intf1 = to.getType("Intf1");
     JClassType intf2 = to.getType("Intf2");
@@ -1618,14 +1612,14 @@
    */
   public void testProblemReporting() throws UnableToCompleteException,
       NotFoundException {
-    Set<CompilationUnit> units = new HashSet<CompilationUnit>();
-    addStandardClasses(units);
+    Set<Resource> resources = new HashSet<Resource>();
+    addStandardClasses(resources);
 
     {
       StringBuilder code = new StringBuilder();
       code.append("public interface TopInterface {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("TopInterface", code));
+      resources.add(new StaticJavaResource("TopInterface", code));
     }
     {
       StringBuilder code = new StringBuilder();
@@ -1633,7 +1627,7 @@
       code.append("public abstract class AbstractSerializable implements\n");
       code.append("    Serializable, TopInterface {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("AbstractSerializable", code));
+      resources.add(new StaticJavaResource("AbstractSerializable", code));
     }
     {
       StringBuilder code = new StringBuilder();
@@ -1641,28 +1635,28 @@
       code.append("public interface PureAbstractSerializable extends \n");
       code.append("    Serializable, TopInterface {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("PureAbstractSerializable", code));
+      resources.add(new StaticJavaResource("PureAbstractSerializable", code));
     }
     {
       StringBuilder code = new StringBuilder();
       code.append("public abstract class PureAbstractClass implements \n");
       code.append("    PureAbstractSerializable {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("PureAbstractClass", code));
+      resources.add(new StaticJavaResource("PureAbstractClass", code));
     }
     {
       StringBuilder code = new StringBuilder();
       code.append("public abstract class PureAbstractClassTwo extends \n");
       code.append("    PureAbstractClass {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("PureAbstractClassTwo", code));
+      resources.add(new StaticJavaResource("PureAbstractClassTwo", code));
     }
     {
       StringBuilder code = new StringBuilder();
       code.append("public class ConcreteNonSerializable implements\n");
       code.append("    TopInterface {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("ConcreteNonSerializable", code));
+      resources.add(new StaticJavaResource("ConcreteNonSerializable", code));
     }
     {
       StringBuilder code = new StringBuilder();
@@ -1670,7 +1664,7 @@
       code.append("public class ConcreteSerializable implements\n");
       code.append("    Serializable, TopInterface {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("ConcreteSerializable", code));
+      resources.add(new StaticJavaResource("ConcreteSerializable", code));
     }
     {
       StringBuilder code = new StringBuilder();
@@ -1678,7 +1672,7 @@
       code.append("public class SubSerializable extends\n");
       code.append("    ConcreteNonSerializable implements Serializable {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("SubSerializable", code));
+      resources.add(new StaticJavaResource("SubSerializable", code));
     }
     {
       StringBuilder code = new StringBuilder();
@@ -1687,10 +1681,10 @@
       code.append("  public ConcreteBadCtor(int i) {\n");
       code.append("  }\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("ConcreteBadCtor", code));
+      resources.add(new StaticJavaResource("ConcreteBadCtor", code));
     }
     TreeLogger logger = createLogger();
-    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, units);
+    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, resources);
 
     SerializableTypeOracleBuilder stob = createSerializableTypeOracleBuilder(
         logger, to);
@@ -1725,8 +1719,8 @@
     problems = new ProblemReport();
     assertFalse(
         "PureAbstractClass should have no possible concrete implementation",
-        stob.computeTypeInstantiability(logger, to.getType("PureAbstractClass"),
-            null, problems).hasInstantiableSubtypes());
+        stob.computeTypeInstantiability(logger,
+            to.getType("PureAbstractClass"), null, problems).hasInstantiableSubtypes());
     assertTrue(
         "PureAbstractClass should have a problem entry as the tested class",
         null != problems.getProblemsForType(to.getType("PureAbstractClass")));
@@ -1762,8 +1756,8 @@
   public void testRawCollection() throws UnableToCompleteException,
       NotFoundException {
 
-    Set<CompilationUnit> units = new HashSet<CompilationUnit>();
-    addStandardClasses(units);
+    Set<Resource> resources = new HashSet<Resource>();
+    addStandardClasses(resources);
 
     {
       StringBuilder code = new StringBuilder();
@@ -1771,7 +1765,7 @@
       code.append("import java.util.Collection;\n");
       code.append("public interface List<T> extends Serializable, Collection<T> {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("List", code));
+      resources.add(new StaticJavaResource("List", code));
     }
     {
       StringBuilder code = new StringBuilder();
@@ -1780,7 +1774,7 @@
       code.append("public class LinkedList<T> implements List<T> {\n");
       code.append("  T head;");
       code.append("}\n");
-      units.add(createMockCompilationUnit("LinkedList", code));
+      resources.add(new StaticJavaResource("LinkedList", code));
     }
     {
       StringBuilder code = new StringBuilder();
@@ -1791,11 +1785,11 @@
       // we get here from a raw collection.
       // code.append(" Object obj;\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("RandomClass", code));
+      resources.add(new StaticJavaResource("RandomClass", code));
     }
 
     TreeLogger logger = createLogger();
-    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, units);
+    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, resources);
 
     JGenericType list = to.getType("List").isGenericType();
     JGenericType linkedList = to.getType("LinkedList").isGenericType();
@@ -1819,8 +1813,8 @@
    */
   public void testRawTypes() throws UnableToCompleteException,
       NotFoundException {
-    Set<CompilationUnit> units = new HashSet<CompilationUnit>();
-    addStandardClasses(units);
+    Set<Resource> resources = new HashSet<Resource>();
+    addStandardClasses(resources);
 
     {
       StringBuilder code = new StringBuilder();
@@ -1828,7 +1822,7 @@
       code.append("public class A<T extends SerializableClass> implements Serializable {\n");
       code.append("  T x;\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("A", code));
+      resources.add(new StaticJavaResource("A", code));
     }
 
     {
@@ -1836,11 +1830,11 @@
       code.append("import java.io.Serializable;\n");
       code.append("public class SerializableClass implements Serializable {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("SerializableClass", code));
+      resources.add(new StaticJavaResource("SerializableClass", code));
     }
 
     TreeLogger logger = createLogger();
-    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, units);
+    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, resources);
 
     JGenericType a = to.getType("A").isGenericType();
     JRawType rawA = a.getRawType();
@@ -1865,8 +1859,8 @@
    */
   public void testRootTypeParameterWithSelfInBounds()
       throws UnableToCompleteException, NotFoundException {
-    Set<CompilationUnit> units = new HashSet<CompilationUnit>();
-    addStandardClasses(units);
+    Set<Resource> resources = new HashSet<Resource>();
+    addStandardClasses(resources);
 
     {
       StringBuilder code = new StringBuilder();
@@ -1874,11 +1868,11 @@
       code.append("public class A<Ta extends A<Ta>> implements Serializable {\n");
       code.append("  Ta ta;\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("A", code));
+      resources.add(new StaticJavaResource("A", code));
     }
 
     TreeLogger logger = createLogger();
-    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, units);
+    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, resources);
 
     JGenericType a = to.getType("A").isGenericType();
     JClassType rawA = a.getRawType();
@@ -1897,8 +1891,8 @@
    */
   public void testStringArrayArray() throws NotFoundException,
       UnableToCompleteException {
-    Set<CompilationUnit> units = new HashSet<CompilationUnit>();
-    addStandardClasses(units);
+    Set<Resource> resources = new HashSet<Resource>();
+    addStandardClasses(resources);
 
     {
       StringBuilder code = new StringBuilder();
@@ -1907,11 +1901,11 @@
       code.append("  String justOneString;");
       code.append("  String[][] stringsGalore;\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("Data", code));
+      resources.add(new StaticJavaResource("Data", code));
     }
 
     TreeLogger logger = createLogger();
-    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, units);
+    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, resources);
 
     JClassType data = to.getType("Data");
     JClassType string = to.getType(String.class.getCanonicalName());
@@ -1936,15 +1930,15 @@
    */
   public void testSubclassIsAssignable() throws UnableToCompleteException,
       NotFoundException {
-    Set<CompilationUnit> units = new HashSet<CompilationUnit>();
-    addStandardClasses(units);
+    Set<Resource> resources = new HashSet<Resource>();
+    addStandardClasses(resources);
 
     {
       StringBuilder code = new StringBuilder();
       code.append("import java.io.Serializable;\n");
       code.append("public class A<T> implements Serializable {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("A", code));
+      resources.add(new StaticJavaResource("A", code));
     }
 
     {
@@ -1953,7 +1947,7 @@
       code.append("public class B extends A<String> implements Serializable {\n");
       code.append("  Object o;\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("B", code));
+      resources.add(new StaticJavaResource("B", code));
     }
 
     {
@@ -1963,7 +1957,7 @@
       // TODO: rejecting Ser requires a better pruner in STOB
       // code.append(" Ser ser;\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("C", code));
+      resources.add(new StaticJavaResource("C", code));
     }
 
     {
@@ -1971,11 +1965,11 @@
       code.append("import java.io.Serializable;\n");
       code.append("public class Ser implements Serializable {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("Ser", code));
+      resources.add(new StaticJavaResource("Ser", code));
     }
 
     TreeLogger logger = createLogger();
-    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, units);
+    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, resources);
 
     JGenericType a = to.getType("A").isGenericType();
     JClassType b = to.getType("B");
@@ -2010,15 +2004,15 @@
    */
   public void testSubclassWithNewInstantiableTypeParameters()
       throws UnableToCompleteException, NotFoundException {
-    Set<CompilationUnit> units = new HashSet<CompilationUnit>();
-    addStandardClasses(units);
+    Set<Resource> resources = new HashSet<Resource>();
+    addStandardClasses(resources);
 
     {
       StringBuilder code = new StringBuilder();
       code.append("import java.io.Serializable;\n");
       code.append("public class A implements Serializable {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("A", code));
+      resources.add(new StaticJavaResource("A", code));
     }
 
     {
@@ -2027,7 +2021,7 @@
       code.append("public class B<T extends C> extends A {\n");
       code.append("  T c;\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("B", code));
+      resources.add(new StaticJavaResource("B", code));
     }
 
     {
@@ -2035,11 +2029,11 @@
       code.append("import java.io.Serializable;\n");
       code.append("public class C implements Serializable {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("C", code));
+      resources.add(new StaticJavaResource("C", code));
     }
 
     TreeLogger logger = createLogger();
-    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, units);
+    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, resources);
 
     JClassType a = to.getType("A");
     JRawType rawB = to.getType("B").isGenericType().getRawType();
@@ -2063,15 +2057,15 @@
    */
   public void testSubclassWithNewTypeParameterComparedToAnImplementedInterface()
       throws UnableToCompleteException, NotFoundException {
-    Set<CompilationUnit> units = new HashSet<CompilationUnit>();
-    addStandardClasses(units);
+    Set<Resource> resources = new HashSet<Resource>();
+    addStandardClasses(resources);
 
     {
       StringBuilder code = new StringBuilder();
       code.append("import java.io.Serializable;\n");
       code.append("public interface Intf<T> extends Serializable {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("Intf", code));
+      resources.add(new StaticJavaResource("Intf", code));
     }
 
     {
@@ -2079,7 +2073,7 @@
       code.append("import java.io.Serializable;\n");
       code.append("public class Bar<T> implements Serializable {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("Bar", code));
+      resources.add(new StaticJavaResource("Bar", code));
     }
 
     {
@@ -2088,7 +2082,7 @@
       code.append("public class Foo<T extends Ser> extends Bar<T> implements Intf<String> {\n");
       code.append("  T x;\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("Foo", code));
+      resources.add(new StaticJavaResource("Foo", code));
     }
 
     {
@@ -2096,11 +2090,11 @@
       code.append("import java.io.Serializable;\n");
       code.append("public class Ser implements Serializable {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("Ser", code));
+      resources.add(new StaticJavaResource("Ser", code));
     }
 
     TreeLogger logger = createLogger();
-    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, units);
+    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, resources);
 
     JGenericType intf = to.getType("Intf").isGenericType();
     JClassType foo = to.getType("Foo");
@@ -2132,15 +2126,15 @@
    */
   public void testSubclassWithNewUninstantiableTypeParameters()
       throws UnableToCompleteException, NotFoundException {
-    Set<CompilationUnit> units = new HashSet<CompilationUnit>();
-    addStandardClasses(units);
+    Set<Resource> resources = new HashSet<Resource>();
+    addStandardClasses(resources);
 
     {
       StringBuilder code = new StringBuilder();
       code.append("import java.io.Serializable;\n");
       code.append("public class A implements Serializable {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("A", code));
+      resources.add(new StaticJavaResource("A", code));
     }
 
     {
@@ -2149,11 +2143,11 @@
       code.append("public class B<T> extends A {\n");
       code.append("  T x;\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("B", code));
+      resources.add(new StaticJavaResource("B", code));
     }
 
     TreeLogger logger = createLogger();
-    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, units);
+    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, resources);
 
     JClassType a = to.getType("A");
 
@@ -2171,8 +2165,8 @@
    */
   public void testTransient() throws UnableToCompleteException,
       NotFoundException {
-    Set<CompilationUnit> units = new HashSet<CompilationUnit>();
-    addStandardClasses(units);
+    Set<Resource> resources = new HashSet<Resource>();
+    addStandardClasses(resources);
 
     {
       StringBuilder code = new StringBuilder();
@@ -2182,7 +2176,7 @@
       code.append("  transient ServerOnly1 serverOnly1;\n");
       code.append("  @GwtTransient ServerOnly2 serverOnly2;\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("A", code));
+      resources.add(new StaticJavaResource("A", code));
     }
 
     {
@@ -2190,7 +2184,7 @@
       code.append("import java.io.Serializable;\n");
       code.append("class ServerOnly1 implements Serializable {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("ServerOnly1", code));
+      resources.add(new StaticJavaResource("ServerOnly1", code));
     }
 
     {
@@ -2198,11 +2192,11 @@
       code.append("import java.io.Serializable;\n");
       code.append("class ServerOnly2 implements Serializable {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("ServerOnly2", code));
+      resources.add(new StaticJavaResource("ServerOnly2", code));
     }
 
     TreeLogger logger = createLogger();
-    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, units);
+    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, resources);
 
     JClassType a = to.getType("A");
     JClassType serverOnly1 = to.getType("ServerOnly1");
@@ -2226,60 +2220,60 @@
    * @throws NotFoundException
    */
   public void testTypeConstrainer() throws NotFoundException {
-    Set<CompilationUnit> units = new HashSet<CompilationUnit>();
-    addStandardClasses(units);
+    Set<Resource> resources = new HashSet<Resource>();
+    addStandardClasses(resources);
 
     {
       StringBuilder code = new StringBuilder();
       code.append("public interface Intf1 {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("Intf1", code));
+      resources.add(new StaticJavaResource("Intf1", code));
     }
     {
       StringBuilder code = new StringBuilder();
       code.append("public interface Intf2 {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("Intf2", code));
+      resources.add(new StaticJavaResource("Intf2", code));
     }
     {
       StringBuilder code = new StringBuilder();
       code.append("public interface Intf3 {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("Intf3", code));
+      resources.add(new StaticJavaResource("Intf3", code));
     }
     {
       StringBuilder code = new StringBuilder();
       code.append("public class Implements12 implements Intf1, Intf2 {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("Implements12", code));
+      resources.add(new StaticJavaResource("Implements12", code));
     }
     {
       StringBuilder code = new StringBuilder();
       code.append("public class ImplementsNeither {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("ImplementsNeither", code));
+      resources.add(new StaticJavaResource("ImplementsNeither", code));
     }
     {
       StringBuilder code = new StringBuilder();
       code.append("public class Sup {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("Sup", code));
+      resources.add(new StaticJavaResource("Sup", code));
     }
     {
       StringBuilder code = new StringBuilder();
       code.append("public class Sub extends Sup {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("Sub", code));
+      resources.add(new StaticJavaResource("Sub", code));
     }
     {
       StringBuilder code = new StringBuilder();
       code.append("public class Holder<T> {\n");
       code.append("  T x;\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("Holder", code));
+      resources.add(new StaticJavaResource("Holder", code));
     }
     TreeLogger logger = createLogger();
-    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, units);
+    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, resources);
 
     JClassType intf1 = to.getType("Intf1");
     JClassType intf2 = to.getType("Intf2");
@@ -2351,8 +2345,8 @@
    */
   public void testTypeParametersInRootTypes1()
       throws UnableToCompleteException, NotFoundException {
-    Set<CompilationUnit> units = new HashSet<CompilationUnit>();
-    addStandardClasses(units);
+    Set<Resource> resources = new HashSet<Resource>();
+    addStandardClasses(resources);
 
     {
       StringBuilder code = new StringBuilder();
@@ -2360,7 +2354,7 @@
       code.append("public class A<T> implements Serializable {\n");
       code.append("  T t;\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("A", code));
+      resources.add(new StaticJavaResource("A", code));
     }
 
     {
@@ -2368,11 +2362,11 @@
       code.append("import java.io.Serializable;\n");
       code.append("public class B implements Serializable {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("B", code));
+      resources.add(new StaticJavaResource("B", code));
     }
 
     TreeLogger logger = createLogger();
-    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, units);
+    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, resources);
 
     JGenericType a = to.getType("A").isGenericType();
     JRawType rawA = a.getRawType();
@@ -2404,8 +2398,8 @@
    */
   public void testTypeParametersInRootTypes2()
       throws UnableToCompleteException, NotFoundException {
-    Set<CompilationUnit> units = new HashSet<CompilationUnit>();
-    addStandardClasses(units);
+    Set<Resource> resources = new HashSet<Resource>();
+    addStandardClasses(resources);
 
     {
       StringBuilder code = new StringBuilder();
@@ -2413,7 +2407,7 @@
       code.append("public abstract class A<U extends B> implements Serializable {\n");
       code.append("  <V extends C>  V getFoo() { return null; }\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("A", code));
+      resources.add(new StaticJavaResource("A", code));
     }
 
     {
@@ -2421,7 +2415,7 @@
       code.append("import java.io.Serializable;\n");
       code.append("public class B implements Serializable {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("B", code));
+      resources.add(new StaticJavaResource("B", code));
     }
 
     {
@@ -2429,11 +2423,11 @@
       code.append("import java.io.Serializable;\n");
       code.append("public class C implements Serializable {\n");
       code.append("}\n");
-      units.add(createMockCompilationUnit("C", code));
+      resources.add(new StaticJavaResource("C", code));
     }
 
     TreeLogger logger = createLogger();
-    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, units);
+    TypeOracle to = TypeOracleTestingUtils.buildTypeOracle(logger, resources);
 
     JGenericType a = to.getType("A").isGenericType();
     JClassType b = to.getType("B");
diff --git a/user/test/com/google/gwt/user/rebind/rpc/TypeHierarchyUtilsTest.java b/user/test/com/google/gwt/user/rebind/rpc/TypeHierarchyUtilsTest.java
index f9bf8d9..9d5beca 100644
--- a/user/test/com/google/gwt/user/rebind/rpc/TypeHierarchyUtilsTest.java
+++ b/user/test/com/google/gwt/user/rebind/rpc/TypeHierarchyUtilsTest.java
@@ -19,9 +19,9 @@
 import com.google.gwt.core.ext.typeinfo.JClassType;
 import com.google.gwt.core.ext.typeinfo.NotFoundException;
 import com.google.gwt.core.ext.typeinfo.TypeOracle;
-import com.google.gwt.dev.javac.CompilationUnit;
-import com.google.gwt.dev.javac.MockCompilationUnit;
 import com.google.gwt.dev.javac.TypeOracleTestingUtils;
+import com.google.gwt.dev.javac.impl.StaticJavaResource;
+import com.google.gwt.dev.resource.Resource;
 import com.google.gwt.dev.util.log.PrintWriterTreeLogger;
 
 import junit.framework.TestCase;
@@ -37,26 +37,26 @@
 public class TypeHierarchyUtilsTest extends TestCase {
   private static TreeLogger createLogger() {
     PrintWriterTreeLogger logger = new PrintWriterTreeLogger(new PrintWriter(
-        System.err));
+        System.err, true));
     logger.setMaxDetail(TreeLogger.ERROR);
     return logger;
   }
 
   public void testParameterizedInterface() throws NotFoundException {
-    Set<CompilationUnit> units = new HashSet<CompilationUnit>();
+    Set<Resource> resources = new HashSet<Resource>();
     {
       StringBuilder code = new StringBuilder();
       code.append("interface A<T> { }\n");
-      units.add(createMockCompilationUnit("A", code));
+      resources.add(new StaticJavaResource("A", code));
     }
     {
       StringBuilder code = new StringBuilder();
       code.append("interface B extends A<String> { }\n");
-      units.add(createMockCompilationUnit("A", code));
+      resources.add(new StaticJavaResource("B", code));
     }
     TreeLogger logger = createLogger();
     TypeOracle to = TypeOracleTestingUtils.buildStandardTypeOracleWith(logger,
-        units);
+        resources);
     JClassType a = to.getType("A");
     JClassType b = to.getType("B");
 
@@ -64,9 +64,4 @@
     assertEquals(1, subtypesOfA.size());
     assertTrue(subtypesOfA.contains(b));
   }
-
-  private MockCompilationUnit createMockCompilationUnit(final String qname,
-      StringBuilder code) {
-    return new MockCompilationUnit(qname, code.toString());
-  }
 }