Revision: 9354
Author: con...@google.com
Date: Fri Dec 3 05:03:49 2010
Log: In CompilingClassLoader, refuse to load a class if its compilation
unit has errors.
Review at http://gwt-code-reviews.appspot.com/1167801
Review by: sco...@google.com
http://code.google.com/p/google-web-toolkit/source/detail?r=9354
Modified:
/trunk/dev/core/src/com/google/gwt/dev/shell/CompilingClassLoader.java
=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/shell/CompilingClassLoader.java
Wed Dec 1 13:52:36 2010
+++ /trunk/dev/core/src/com/google/gwt/dev/shell/CompilingClassLoader.java
Fri Dec 3 05:03:49 2010
@@ -1018,10 +1018,7 @@
// Get the bytes, compiling if necessary.
byte[] classBytes = findClassBytes(className);
- if (classBytes == null) {
- throw new ClassNotFoundException(className);
- }
-
+
if (HasAnnotation.hasAnnotation(classBytes, GwtScriptOnly.class)) {
scriptOnlyClasses.add(className);
maybeInitializeScriptOnlyClassLoader();
@@ -1113,7 +1110,7 @@
}
@SuppressWarnings("deprecation")
- private byte[] findClassBytes(String className) {
+ private byte[] findClassBytes(String className) throws
ClassNotFoundException {
if (JavaScriptHost.class.getName().equals(className)) {
// No need to rewrite.
return javaScriptHostBytes;
@@ -1136,6 +1133,12 @@
CompilationUnit unit = (compiledClass == null)
? getUnitForClassName(lookupClassName) : compiledClass.getUnit();
+
+ if (unit != null && unit.isError()) {
+ throw new ClassNotFoundException("Cannot load class " + className
+ + " because it has errors.");
+ }
+
if (emmaAvailable) {
/*
* build the map for anonymous classes. Do so only if unit has
anonymous
@@ -1148,11 +1151,10 @@
&& unit.hasAnonymousClasses() && jsniMethods != null
&& jsniMethods.size() > 0 && !unit.createdClassMapping()) {
if (!unit.constructAnonymousClassMappings(logger)) {
- logger.log(TreeLogger.ERROR,
+ throw new ClassNotFoundException(
"Our heuristic for mapping anonymous classes between
compilers "
+ "failed. Unsafe to continue because the wrong jsni
code "
+ "could end up running. className = " + className);
- return null;
}
}
}
@@ -1199,6 +1201,10 @@
}
classBytes = newBytes;
}
+
+ if (classBytes == null) {
+ throw new ClassNotFoundException(className);
+ }
return classBytes;
}
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors