Fixes issue 1091, default to warn if not all types in an auto serializable type hierachy are serializable and adds gentler treatment of missing gwt.typeArgs. If there is a missing gwt.typeArgs the generator will emit a warning and pull in all types that qualify for serilization. This will allow code that was missing gwt.typeArgs to continue to work at the cost of a larger application size.
Patch by: mmendez
Review by: bruce
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@1116 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/user/RemoteService.gwt.xml b/user/src/com/google/gwt/user/RemoteService.gwt.xml
index 489714f..ce179ac 100644
--- a/user/src/com/google/gwt/user/RemoteService.gwt.xml
+++ b/user/src/com/google/gwt/user/RemoteService.gwt.xml
@@ -34,8 +34,14 @@
-->
<define-property name="gwt.allowUnserializableSubtypesOfAutoSerializableTypes" values="true,false" />
- <!-- Default warning enabled. -->
- <set-property name="gwt.allowUnserializableSubtypesOfAutoSerializableTypes" value="false"/>
+ <!--
+ Default to a warning if any of the subtypes of an auto serializable
+ type are not also auto serializable.
+
+ TODO: We should tighten this since it really is an error. However, to
+ give people time to transition we will just make it a warning for now.
+ -->
+ <set-property name="gwt.allowUnserializableSubtypesOfAutoSerializableTypes" value="true"/>
<!--
Declare a property to determine whether or warnings for final instance
diff --git a/user/src/com/google/gwt/user/rebind/rpc/SerializableTypeOracleBuilder.java b/user/src/com/google/gwt/user/rebind/rpc/SerializableTypeOracleBuilder.java
index 10498a6..d84af23 100644
--- a/user/src/com/google/gwt/user/rebind/rpc/SerializableTypeOracleBuilder.java
+++ b/user/src/com/google/gwt/user/rebind/rpc/SerializableTypeOracleBuilder.java
@@ -114,7 +114,7 @@
static final class TypeState {
private final String state;
- private TypeState(String state) {
+ protected TypeState(String state) {
this.state = state;
}
@@ -653,8 +653,7 @@
}
if (type.isAbstract() && type.getSubtypes().length == 0) {
- setUnserializableAndLog(logger, TreeLogger.ERROR,
- "Is abstract and it has no serializable subtypes", type);
+ // Just ignore pure, abstract classes that have no subtypes
return;
}
@@ -707,11 +706,12 @@
if (mti.qualifiesForAutoSerialization()) {
if (nSerializableSubtypes < nSubtypes) {
- if (!allowUnserializableSubtypesOfAutoSerializableTypes
- || nSerializableSubtypes == 0) {
- setUnserializableAndLog(logger, TreeLogger.ERROR,
- "Not all subtypes are serializable", type);
- }
+ setUnserializableAndLog(logger,
+ allowUnserializableSubtypesOfAutoSerializableTypes
+ ? TreeLogger.WARN : TreeLogger.ERROR,
+ "Not all subtypes of the automatically serializable type '"
+ + type.getQualifiedSourceName()
+ + "' are themselves automatically serializable", type);
}
} else if (!mti.qualifiesForManualSerialization()
&& nSerializableSubtypes == 0) {
@@ -776,12 +776,27 @@
if (classOrInterface != null) {
if (classOrInterface.isAssignableTo(collectionClass)
|| classOrInterface.isAssignableTo(mapClass)) {
- logger.branch(
+ TreeLogger localLogger = logger.branch(
TreeLogger.WARN,
"Type '"
+ type.getQualifiedSourceName()
- + "' should be parameterized to ensure that the correct types are considered for serialization; add a gwt.typeArgs javadoc annotation to correct this warning",
+ + "' should be parameterized to help the compiler produce the smallest code size possible for your module. Since the gwt.typeArgs javadoc annotation is missing, all subtypes of Object will be analyzed for serializability even if they are not directly or indirectly used",
null);
+
+ /*
+ * This will pull in the world and the set of serializable types will be
+ * larger than it needs to be. We exclude types that do not qualify for
+ * serialization to avoid generating false errors due to types that do
+ * not qualify for serialization and have no serializable subtypes.
+ */
+ JClassType[] allTypes = typeOracle.getJavaLangObject().getSubtypes();
+ for (int i = 0; i < allTypes.length; ++i) {
+ JClassType cls = allTypes[i];
+ MetaTypeInfo mti = getMetaTypeInfo(cls);
+ if (mti.qualifiesForSerialization()) {
+ checkType(localLogger, cls, true);
+ }
+ }
}
}
}