Emma support ignores super-source files. This change required propagating the
super-source information through various stages of the compiler.
Patch by: amitmanjhi
Review by: spoon
git-svn-id: https://google-web-toolkit.googlecode.com/svn/releases/1.6@4192 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/dev/javac/CompilationUnit.java b/dev/core/src/com/google/gwt/dev/javac/CompilationUnit.java
index 826184d..210995c 100644
--- a/dev/core/src/com/google/gwt/dev/javac/CompilationUnit.java
+++ b/dev/core/src/com/google/gwt/dev/javac/CompilationUnit.java
@@ -189,6 +189,12 @@
public abstract boolean isGenerated();
/**
+ *
+ * @return true if the Compilation Unit is from a super-source.
+ */
+ public abstract boolean isSuperSource();
+
+ /**
* Overridden to finalize; always returns {@link #getDisplayLocation()}.
*/
public final String toString() {
diff --git a/dev/core/src/com/google/gwt/dev/javac/JavaSourceFile.java b/dev/core/src/com/google/gwt/dev/javac/JavaSourceFile.java
index c1bf5f7..571b501 100644
--- a/dev/core/src/com/google/gwt/dev/javac/JavaSourceFile.java
+++ b/dev/core/src/com/google/gwt/dev/javac/JavaSourceFile.java
@@ -63,6 +63,11 @@
}
/**
+ * @return true if the corresponding source comes from super-source.
+ */
+ public abstract boolean isSuperSource();
+
+ /**
* Returns the Java code contained in this source file. May return
* <code>null</code> if this {@link JavaSourceFile} has been invalidated by
* its containing {@link JavaSourceOracle}. This method may be expensive as
@@ -76,4 +81,5 @@
public final String toString() {
return getLocation();
}
+
}
diff --git a/dev/core/src/com/google/gwt/dev/javac/impl/FileCompilationUnit.java b/dev/core/src/com/google/gwt/dev/javac/impl/FileCompilationUnit.java
index d2fee22..568791a 100644
--- a/dev/core/src/com/google/gwt/dev/javac/impl/FileCompilationUnit.java
+++ b/dev/core/src/com/google/gwt/dev/javac/impl/FileCompilationUnit.java
@@ -63,4 +63,9 @@
public boolean isGenerated() {
return false;
}
+
+ @Override
+ public boolean isSuperSource() {
+ return false;
+ }
}
\ No newline at end of file
diff --git a/dev/core/src/com/google/gwt/dev/javac/impl/JavaSourceOracleImpl.java b/dev/core/src/com/google/gwt/dev/javac/impl/JavaSourceOracleImpl.java
index 88e2406..e2d7145 100644
--- a/dev/core/src/com/google/gwt/dev/javac/impl/JavaSourceOracleImpl.java
+++ b/dev/core/src/com/google/gwt/dev/javac/impl/JavaSourceOracleImpl.java
@@ -85,6 +85,11 @@
}
@Override
+ public boolean isSuperSource() {
+ return resource.wasRerooted();
+ }
+
+ @Override
public String readSource() {
if (resource != null) {
InputStream contents = resource.openContents();
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 7f543af..c3e7c9e 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
@@ -63,6 +63,11 @@
}
@Override
+ public boolean isSuperSource() {
+ return sourceFile.isSuperSource();
+ }
+
+ @Override
protected void dumpSource() {
sourceCode = null;
}
diff --git a/dev/core/src/com/google/gwt/dev/resource/Resource.java b/dev/core/src/com/google/gwt/dev/resource/Resource.java
index 6d61cce..0a49ff6 100644
--- a/dev/core/src/com/google/gwt/dev/resource/Resource.java
+++ b/dev/core/src/com/google/gwt/dev/resource/Resource.java
@@ -64,8 +64,8 @@
}
/**
- * Returns the contents of the resource. May return <code>null</code> if
- * this {@link Resource} has been invalidated by its containing
+ * Returns the contents of the resource. May return <code>null</code> if this
+ * {@link Resource} has been invalidated by its containing
* {@link ResourceOracle}. The caller is responsible for closing the stream.
*/
public abstract InputStream openContents();
@@ -77,4 +77,7 @@
public final String toString() {
return getLocation();
}
+
+ public abstract boolean wasRerooted();
+
}
diff --git a/dev/core/src/com/google/gwt/dev/resource/impl/FileResource.java b/dev/core/src/com/google/gwt/dev/resource/impl/FileResource.java
index dab8e71..a3183cc 100644
--- a/dev/core/src/com/google/gwt/dev/resource/impl/FileResource.java
+++ b/dev/core/src/com/google/gwt/dev/resource/impl/FileResource.java
@@ -94,6 +94,11 @@
}
}
+ @Override
+ public boolean wasRerooted() {
+ return false;
+ }
+
private long lastModifiedSeconds(File file) {
return file.lastModified() / 1000;
}
diff --git a/dev/core/src/com/google/gwt/dev/resource/impl/ResourceOracleImpl.java b/dev/core/src/com/google/gwt/dev/resource/impl/ResourceOracleImpl.java
index b04fcf4..0245008 100644
--- a/dev/core/src/com/google/gwt/dev/resource/impl/ResourceOracleImpl.java
+++ b/dev/core/src/com/google/gwt/dev/resource/impl/ResourceOracleImpl.java
@@ -117,6 +117,11 @@
public InputStream openContents() {
return resource.openContents();
}
+
+ @Override
+ public boolean wasRerooted() {
+ return true;
+ }
}
public static ClassPathEntry createEntryForUrl(TreeLogger logger, URL url)
diff --git a/dev/core/src/com/google/gwt/dev/resource/impl/ZipFileResource.java b/dev/core/src/com/google/gwt/dev/resource/impl/ZipFileResource.java
index 1920e86..3c15743 100644
--- a/dev/core/src/com/google/gwt/dev/resource/impl/ZipFileResource.java
+++ b/dev/core/src/com/google/gwt/dev/resource/impl/ZipFileResource.java
@@ -90,4 +90,9 @@
return null;
}
}
+
+ @Override
+ public boolean wasRerooted() {
+ return false;
+ }
}
diff --git a/dev/core/src/com/google/gwt/dev/shell/CompilingClassLoader.java b/dev/core/src/com/google/gwt/dev/shell/CompilingClassLoader.java
index ef4dd2c..fa29157 100644
--- a/dev/core/src/com/google/gwt/dev/shell/CompilingClassLoader.java
+++ b/dev/core/src/com/google/gwt/dev/shell/CompilingClassLoader.java
@@ -52,8 +52,8 @@
/**
* An isolated {@link ClassLoader} for running all user code. All user files are
- * compiled from source code byte a {@link ByteCodeCompiler}. After
- * compilation, some byte code rewriting is performed to support
+ * compiled from source code byte a {@link ByteCodeCompiler}. After compilation,
+ * some byte code rewriting is performed to support
* <code>JavaScriptObject</code> and its subtypes.
*
* TODO: we should refactor this class to move the getClassInfoByDispId,
@@ -64,8 +64,8 @@
public final class CompilingClassLoader extends ClassLoader {
/**
- * Oracle that can answer questions about
- * {@link DispatchClassInfo DispatchClassInfos}.
+ * Oracle that can answer questions about {@link DispatchClassInfo
+ * DispatchClassInfos}.
*/
private final class DispatchClassInfoOracle {
@@ -551,8 +551,8 @@
* was previously cached and has not been garbage collected.
*
* @param javaObject the Object being wrapped
- * @return the mapped wrapper, or <code>null</code> if the Java object
- * mapped or if the wrapper has been garbage collected
+ * @return the mapped wrapper, or <code>null</code> if the Java object mapped
+ * or if the wrapper has been garbage collected
*/
public Object getWrapperForObject(Object javaObject) {
return weakJavaWrapperCache.get(javaObject);
@@ -652,8 +652,13 @@
injectJsniFor(compiledClass);
byte[] classBytes = compiledClass.getBytes();
- classBytes = emmaStrategy.getEmmaClassBytes(classBytes, lookupClassName,
- compiledClass.getUnit().getLastModified());
+ if (!compiledClass.getUnit().isSuperSource()) {
+ classBytes = emmaStrategy.getEmmaClassBytes(classBytes,
+ lookupClassName, compiledClass.getUnit().getLastModified());
+ } else {
+ logger.log(TreeLogger.SPAM, "no emma instrumentation for "
+ + lookupClassName + " because it is from super-source");
+ }
if (classRewriter != null) {
byte[] newBytes = classRewriter.rewrite(className, classBytes);
if (CLASS_DUMP) {
diff --git a/dev/core/src/com/google/gwt/dev/shell/StandardGeneratorContext.java b/dev/core/src/com/google/gwt/dev/shell/StandardGeneratorContext.java
index 06ba50e..6433045 100644
--- a/dev/core/src/com/google/gwt/dev/shell/StandardGeneratorContext.java
+++ b/dev/core/src/com/google/gwt/dev/shell/StandardGeneratorContext.java
@@ -127,6 +127,11 @@
return file != null;
}
+ @Override
+ public boolean isSuperSource() {
+ return false;
+ }
+
public void setFile(File file) {
assert (file.exists() && file.canRead());
this.file = file;
diff --git a/dev/core/test/com/google/gwt/dev/javac/MockCompilationUnit.java b/dev/core/test/com/google/gwt/dev/javac/MockCompilationUnit.java
index 4014c8d..7a0b99b 100644
--- a/dev/core/test/com/google/gwt/dev/javac/MockCompilationUnit.java
+++ b/dev/core/test/com/google/gwt/dev/javac/MockCompilationUnit.java
@@ -52,4 +52,9 @@
public boolean isGenerated() {
return true;
}
+
+ @Override
+ public boolean isSuperSource() {
+ return false;
+ }
}
diff --git a/dev/core/test/com/google/gwt/dev/javac/impl/MockJavaSourceFile.java b/dev/core/test/com/google/gwt/dev/javac/impl/MockJavaSourceFile.java
index 1018edb..c7d0bbb 100644
--- a/dev/core/test/com/google/gwt/dev/javac/impl/MockJavaSourceFile.java
+++ b/dev/core/test/com/google/gwt/dev/javac/impl/MockJavaSourceFile.java
@@ -70,7 +70,13 @@
}
@Override
+ public boolean isSuperSource() {
+ return false;
+ }
+
+ @Override
public String readSource() {
return source;
}
+
}
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 b35cfda..bcce637 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
@@ -57,5 +57,10 @@
return new ByteArrayInputStream(Util.getBytes(getContent().toString()));
}
+ @Override
+ public boolean wasRerooted() {
+ return false;
+ }
+
protected abstract CharSequence getContent();
}
diff --git a/dev/core/test/com/google/gwt/dev/resource/impl/MockAbstractResource.java b/dev/core/test/com/google/gwt/dev/resource/impl/MockAbstractResource.java
index 992fdcb..afca6d4 100644
--- a/dev/core/test/com/google/gwt/dev/resource/impl/MockAbstractResource.java
+++ b/dev/core/test/com/google/gwt/dev/resource/impl/MockAbstractResource.java
@@ -69,4 +69,9 @@
public void setStale(boolean isStale) {
this.isStale = isStale;
}
+
+ @Override
+ public boolean wasRerooted() {
+ return false;
+ }
}
\ No newline at end of file
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 ede0be2..3d71400 100644
--- a/dev/core/test/com/google/gwt/dev/shell/StandardGeneratorContextTest.java
+++ b/dev/core/test/com/google/gwt/dev/shell/StandardGeneratorContextTest.java
@@ -123,6 +123,12 @@
public InputStream openContents() {
return new ByteArrayInputStream(Util.getBytes("w00t!"));
}
+
+ @Override
+ public boolean wasRerooted() {
+ return false;
+ }
+
};
}
return null;