Update CompiledClass to use the handy DiskCacheToken class.  Makes it
consistent with CachedCompilationUnit.

Patch by: stephen.haberman
Review by: zundel
Review at: http://gwt-code-reviews.appspot.com/1464801/


git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@10364 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/dev/javac/CompiledClass.java b/dev/core/src/com/google/gwt/dev/javac/CompiledClass.java
index 85f42de..89d1e45 100644
--- a/dev/core/src/com/google/gwt/dev/javac/CompiledClass.java
+++ b/dev/core/src/com/google/gwt/dev/javac/CompiledClass.java
@@ -17,6 +17,7 @@
 
 import com.google.gwt.dev.javac.TypeOracleMediator.TypeData;
 import com.google.gwt.dev.util.DiskCache;
+import com.google.gwt.dev.util.DiskCacheToken;
 import com.google.gwt.dev.util.StringInterner;
 import com.google.gwt.dev.util.Name.InternalName;
 
@@ -24,9 +25,6 @@
 import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException;
 import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer;
 
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
 import java.io.Serializable;
 
 /**
@@ -48,7 +46,7 @@
    * A token to retrieve this object's bytes from the disk cache. byte code is
    * placed in the cache when the object is deserialized.
    */
-  private transient long cacheToken;
+  private final DiskCacheToken classBytesToken;
   private transient NameEnvironmentAnswer nameEnvironmentAnswer;
 
   /**
@@ -67,7 +65,7 @@
     this.enclosingClass = enclosingClass;
     this.internalName = StringInterner.get().intern(internalName);
     this.sourceName = StringInterner.get().intern(InternalName.toSourceName(internalName));
-    this.cacheToken = diskCache.writeByteArray(classBytes);
+    this.classBytesToken = new DiskCacheToken(diskCache.writeByteArray(classBytes));
     this.isLocal = isLocal;
   }
 
@@ -75,7 +73,7 @@
    * Returns the bytes of the compiled class.
    */
   public byte[] getBytes() {
-    return diskCache.readByteArray(cacheToken);
+    return classBytesToken.readByteArray();
   }
 
   public CompiledClass getEnclosingClass() {
@@ -153,13 +151,4 @@
     this.unit = unit;
   }
 
-  private void readObject(ObjectInputStream inputStream) throws ClassNotFoundException, IOException {
-    inputStream.defaultReadObject();
-    this.cacheToken = diskCache.transferFromStream(inputStream);
-  }
-
-  private void writeObject(ObjectOutputStream outputStream) throws IOException {
-    outputStream.defaultWriteObject();
-    diskCache.transferToStream(cacheToken, outputStream);
-  }
 }