Exposure computer will skip classes that are not field serializable. Use the erasure of the superclass when computing immediate subtypes. Refactored STOB field serialziabiliy and instantiability checks to allow them to be reused by the type parameter exposure computer.
Fixes build break of dynatable.
Patch by: mmendez, spoon (pair prog)
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@2899 8db76d5a-ed1c-0410-87a9-c151d255dfc7
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 c0dccfe..e096154 100644
--- a/user/src/com/google/gwt/user/rebind/rpc/SerializableTypeOracleBuilder.java
+++ b/user/src/com/google/gwt/user/rebind/rpc/SerializableTypeOracleBuilder.java
@@ -88,7 +88,6 @@
* </p>
*/
public class SerializableTypeOracleBuilder {
-
interface Path {
Path getParent();
@@ -175,13 +174,9 @@
public TypeInfoComputed(JClassType type, Path path) {
this.type = type;
this.path = path;
- autoSerializable = type.isAssignableTo(isSerializableClass)
- || type.isAssignableTo(serializableClass);
+ autoSerializable = SerializableTypeOracleBuilder.isAutoSerializable(type);
manualSerializer = findCustomFieldSerializer(typeOracle, type);
- directlyImplementsMarker = TypeHierarchyUtils.directlyImplementsInterface(
- type, isSerializableClass)
- || TypeHierarchyUtils.directlyImplementsInterface(type,
- serializableClass);
+ directlyImplementsMarker = directlyImplementsMarkerInterface(type);
}
public JClassType getManualSerializer() {
@@ -293,6 +288,33 @@
private static final JClassType[] NO_JCLASSES = new JClassType[0];
+ static boolean canBeInstantiated(TreeLogger logger, JClassType type,
+ TreeLogger.Type logLevel) {
+ if (type.isEnum() == null) {
+ if (type.isAbstract()) {
+ // Abstract types will be picked up if there is an instantiable
+ // subtype.
+ return false;
+ }
+
+ if (!type.isDefaultInstantiable() && !isManuallySerializable(type)) {
+ // Warn and return false.
+ logger.log(
+ logLevel,
+ "Was not default instantiable (it must have a zero-argument constructor or no constructors at all)",
+ null);
+ return false;
+ }
+ } else {
+ /*
+ * Enums are always instantiable regardless of abstract or default
+ * instantiability.
+ */
+ }
+
+ return true;
+ }
+
/**
* Finds the custom field serializer for a given type.
*
@@ -320,6 +342,17 @@
return customSerializer;
}
+ static boolean isAutoSerializable(JClassType type) {
+ try {
+ JClassType isSerializable = getIsSerializableMarkerInterface(type);
+ JClassType serializable = getSerializableMarkerInterface(type);
+ return type.isAssignableTo(isSerializable)
+ || type.isAssignableTo(serializable);
+ } catch (NotFoundException e) {
+ return false;
+ }
+ }
+
/**
* Returns <code>true</code> if this type is part of the standard java
* packages.
@@ -340,24 +373,6 @@
return false;
}
- /**
- * Returns <code>true</code> if the field qualifies for serialization
- * without considering its type.
- */
- static boolean qualfiesForSerialization(TreeLogger logger, JField field) {
- if (field.isStatic() || field.isTransient()) {
- return false;
- }
-
- if (field.isFinal()) {
- logger.branch(TreeLogger.DEBUG, "Field '" + field.toString()
- + "' will not be serialized because it is final", null);
- return false;
- }
-
- return true;
- }
-
static void recordTypeParametersIn(JType type, Set<JTypeParameter> params) {
JTypeParameter isTypeParameter = type.isTypeParameter();
if (isTypeParameter != null) {
@@ -384,6 +399,96 @@
}
}
+ static boolean shouldConsiderFieldsForSerialization(TreeLogger logger,
+ JClassType type, boolean isSpeculative, TypeFilter filter) {
+ if (!isAllowedByFilter(logger, filter, type, isSpeculative)) {
+ return false;
+ }
+
+ if (!isDeclaredSerializable(type)) {
+ logger.branch(TreeLogger.DEBUG, "Type '"
+ + type.getParameterizedQualifiedSourceName()
+ + "' is not assignable to '" + IsSerializable.class.getName()
+ + "' or '" + Serializable.class.getName()
+ + "' nor does it have a custom field serializer", null);
+ return false;
+ }
+
+ if (isManuallySerializable(type)) {
+ JClassType manualSerializer = findCustomFieldSerializer(type.getOracle(),
+ type);
+ assert (manualSerializer != null);
+
+ List<String> problems = CustomFieldSerializerValidator.validate(
+ manualSerializer, type);
+ if (!problems.isEmpty()) {
+ for (String problem : problems) {
+ logger.branch(getLogLevel(isSpeculative), problem, null);
+ }
+ return false;
+ }
+ } else {
+ assert (isAutoSerializable(type));
+
+ /*
+ * Speculative paths log at DEBUG level, non-speculative ones log at WARN
+ * level.
+ */
+ TreeLogger.Type logLevel = isSpeculative ? TreeLogger.DEBUG
+ : TreeLogger.WARN;
+
+ if (!isAccessibleToSerializer(type)) {
+ // Class is not visible to a serializer class in the same package
+ logger.branch(
+ logLevel,
+ type.getParameterizedQualifiedSourceName()
+ + " is not accessible from a class in its same package; it will be excluded from the set of serializable types",
+ null);
+ return false;
+ }
+
+ if (type.isLocalType()) {
+ // Local types cannot be serialized
+ logger.branch(
+ logLevel,
+ type.getParameterizedQualifiedSourceName()
+ + " is a local type; it will be excluded from the set of serializable types",
+ null);
+ return false;
+ }
+
+ if (type.isMemberType() && !type.isStatic()) {
+ // Non-static member types cannot be serialized
+ logger.branch(
+ logLevel,
+ type.getParameterizedQualifiedSourceName()
+ + " is nested but not static; it will be excluded from the set of serializable types",
+ null);
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Returns <code>true</code> if the field qualifies for serialization
+ * without considering its type.
+ */
+ static boolean shouldConsiderForSerialization(TreeLogger logger, JField field) {
+ if (field.isStatic() || field.isTransient()) {
+ return false;
+ }
+
+ if (field.isFinal()) {
+ logger.branch(TreeLogger.DEBUG, "Field '" + field.toString()
+ + "' will not be serialized because it is final", null);
+ return false;
+ }
+
+ return true;
+ }
+
private static Path createArrayComponentPath(final JArrayType arrayType,
final Path parent) {
return new Path() {
@@ -463,6 +568,17 @@
};
}
+ private static boolean directlyImplementsMarkerInterface(JClassType type) {
+ try {
+ return TypeHierarchyUtils.directlyImplementsInterface(type,
+ getIsSerializableMarkerInterface(type))
+ || TypeHierarchyUtils.directlyImplementsInterface(type,
+ getSerializableMarkerInterface(type));
+ } catch (NotFoundException e) {
+ return false;
+ }
+ }
+
private static JArrayType getArrayType(TypeOracle typeOracle, int rank,
JType component) {
assert (rank > 0);
@@ -477,10 +593,20 @@
return array;
}
+ private static JClassType getIsSerializableMarkerInterface(JClassType type)
+ throws NotFoundException {
+ return type.getOracle().getType(IsSerializable.class.getName());
+ }
+
private static Type getLogLevel(boolean isSpeculative) {
return isSpeculative ? TreeLogger.WARN : TreeLogger.ERROR;
}
+ private static JClassType getSerializableMarkerInterface(JClassType type)
+ throws NotFoundException {
+ return type.getOracle().getType(Serializable.class.getName());
+ }
+
/**
* Returns <code>true</code> if a serializer class could access this type.
*/
@@ -502,6 +628,24 @@
return true;
}
+ private static boolean isAllowedByFilter(TreeLogger logger,
+ TypeFilter filter, JClassType classType, boolean isSpeculative) {
+ if (!filter.isAllowed(classType)) {
+ logger.log(getLogLevel(isSpeculative), "Excluded by type filter ");
+ return false;
+ }
+
+ return true;
+ }
+
+ private static boolean isDeclaredSerializable(JClassType type) {
+ return isAutoSerializable(type) || isManuallySerializable(type);
+ }
+
+ private static boolean isManuallySerializable(JClassType type) {
+ return findCustomFieldSerializer(type.getOracle(), type) != null;
+ }
+
private static void logSerializableTypes(TreeLogger logger,
Set<JClassType> fieldSerializableTypes) {
TreeLogger localLogger = logger.branch(TreeLogger.DEBUG, "Identified "
@@ -521,11 +665,6 @@
*/
private final JClassType collectionClass;
- /**
- * Cache of the {@link JClassType} for {@link IsSerializable}.
- */
- private final JClassType isSerializableClass;
-
private OutputStream logOutputStream;
/**
@@ -535,17 +674,12 @@
private final Map<JClassType, TreeLogger> rootTypes = new LinkedHashMap<JClassType, TreeLogger>();
- /**
- * Cache of the {@link JClassType} for
- * {@link java.io.Serializable Serializable}.
- */
- private final JClassType serializableClass;
-
private TypeFilter typeFilter = DEFAULT_TYPE_FILTER;
private final TypeOracle typeOracle;
- private final TypeParameterExposureComputer typeParameterExposureComputer = new TypeParameterExposureComputer();
+ private final TypeParameterExposureComputer typeParameterExposureComputer = new TypeParameterExposureComputer(
+ typeFilter);
private Set<JTypeParameter> typeParametersInRootTypes = new HashSet<JTypeParameter>();
@@ -569,9 +703,7 @@
try {
collectionClass = typeOracle.getType(Collection.class.getName());
- isSerializableClass = typeOracle.getType(IsSerializable.class.getName());
mapClass = typeOracle.getType(Map.class.getName());
- serializableClass = typeOracle.getType(Serializable.class.getName());
} catch (NotFoundException e) {
logger.log(TreeLogger.ERROR, null, e);
throw new UnableToCompleteException();
@@ -664,6 +796,7 @@
public void setTypeFilter(TypeFilter typeFilter) {
this.typeFilter = typeFilter;
+ typeParameterExposureComputer.setTypeFilter(typeFilter);
}
/**
@@ -834,8 +967,11 @@
}
}
+ // TODO: Figure out logLevel for canBeInstantiated
boolean isInstantiable = parametersOkay
- && qualifiesForSerialization(localLogger, baseType, isSpeculative, path)
+ && shouldConsiderFieldsForSerialization(localLogger, baseType,
+ isSpeculative)
+ && canBeInstantiated(logger, baseType, TreeLogger.WARN)
&& checkFields(localLogger, baseType, isSpeculative, path);
boolean anySubtypes = false;
@@ -867,100 +1003,15 @@
}
/**
- * Returns <code>true</code> if the type qualifies for serialization.
+ * Returns <code>true</code> if the fields of the type should be considered
+ * for serialization.
*
* Default access to allow for testing.
*/
- boolean qualifiesForSerialization(TreeLogger logger, JClassType type,
- boolean isSpeculative, Path parent) {
- TypeInfoComputed typeInfo = getTypeInfoComputed(type, parent);
-
- if (!isAllowedByFilter(logger, type, isSpeculative)) {
- return false;
- }
-
- if (!typeInfo.isDeclaredSerializable()) {
- logger.branch(TreeLogger.DEBUG, "Type '"
- + type.getParameterizedQualifiedSourceName()
- + "' is not assignable to '" + IsSerializable.class.getName()
- + "' or '" + Serializable.class.getName()
- + "' nor does it have a custom field serializer", null);
- return false;
- }
-
- if (typeInfo.isManuallySerializable()) {
- List<String> problems = CustomFieldSerializerValidator.validate(
- typeInfo.getManualSerializer(), type);
- if (!problems.isEmpty()) {
- for (String problem : problems) {
- logger.branch(getLogLevel(isSpeculative), problem, null);
- }
- return false;
- }
- } else {
- assert (typeInfo.isAutoSerializable());
-
- /*
- * Speculative paths log at DEBUG level, non-speculative ones log at WARN
- * level.
- */
- TreeLogger.Type logLevel = isSpeculative ? TreeLogger.DEBUG
- : TreeLogger.WARN;
-
- if (!isAccessibleToSerializer(type)) {
- // Class is not visible to a serializer class in the same package
- logger.branch(
- logLevel,
- type.getParameterizedQualifiedSourceName()
- + " is not accessible from a class in its same package; it will be excluded from the set of serializable types",
- null);
- return false;
- }
-
- if (type.isLocalType()) {
- // Local types cannot be serialized
- logger.branch(
- logLevel,
- type.getParameterizedQualifiedSourceName()
- + " is a local type; it will be excluded from the set of serializable types",
- null);
- return false;
- }
-
- if (type.isMemberType() && !type.isStatic()) {
- // Non-static member types cannot be serialized
- logger.branch(
- logLevel,
- type.getParameterizedQualifiedSourceName()
- + " is nested but not static; it will be excluded from the set of serializable types",
- null);
- return false;
- }
-
- if (type.isEnum() == null) {
- if (type.isAbstract()) {
- // Abstract types will be picked up if there is an instantiable
- // subtype.
- return false;
- }
-
- if (!type.isDefaultInstantiable()) {
- // Warn and return false.
- logger.log(
- logLevel,
- "Was not default instantiable (it must have a zero-argument constructor or no constructors at all)",
- null);
- return false;
- }
- } else {
- /*
- * Enums are always instantiable regardless of abstract or default
- * instantiability.
- */
- }
- }
-
- return true;
+ boolean shouldConsiderFieldsForSerialization(TreeLogger logger,
+ JClassType type, boolean isSpeculative) {
+ return shouldConsiderFieldsForSerialization(logger, type, isSpeculative,
+ typeFilter);
}
/**
@@ -1066,7 +1117,7 @@
+ "' that qualify for serialization", null);
for (JField field : fields) {
- if (!qualfiesForSerialization(localLogger, field)) {
+ if (!shouldConsiderForSerialization(localLogger, field)) {
continue;
}
@@ -1098,6 +1149,10 @@
private boolean checkFields(TreeLogger logger, JClassType classOrInterface,
boolean isSpeculative, Path parent) {
TypeInfoComputed typeInfo = getTypeInfoComputed(classOrInterface, parent);
+ if (classOrInterface.isEnum() != null) {
+ // The fields of an enum are never serialized; they are always okay.
+ return true;
+ }
// Check all super type fields first (recursively).
JClassType superType = classOrInterface.getSuperclass();
@@ -1140,18 +1195,18 @@
* If super does not qualify and I am not directly serializable then I can't
* be serializable.
*/
- boolean subInstantiable = qualifiesForSerialization(subtypeLogger,
- currentSubtype, true, subtypePath);
+ boolean fieldSerializable = shouldConsiderFieldsForSerialization(
+ subtypeLogger, currentSubtype, true);
if (!superIsFieldSerializable) {
- subInstantiable &= typeInfo.isDirectlySerializable();
+ fieldSerializable &= typeInfo.isDirectlySerializable();
}
- if (subInstantiable) {
+ if (fieldSerializable) {
if (checkSuperFields) {
- subInstantiable &= checkFields(subtypeLogger, typeInfo.getType(), true,
- subtypePath);
+ fieldSerializable &= checkFields(subtypeLogger, typeInfo.getType(),
+ true, subtypePath);
} else {
- subInstantiable &= checkDeclaredFields(subtypeLogger, typeInfo, true,
+ fieldSerializable &= checkDeclaredFields(subtypeLogger, typeInfo, true,
subtypePath);
}
}
@@ -1167,10 +1222,10 @@
&& immediateSubtype.isClass() != null;
anySubtypes |= checkSubtypes(localLogger, originalType, baseType,
instSubtypes, typeArgs, path, immediateSubtype, checkSuperFields,
- subInstantiable);
+ fieldSerializable);
}
- if (!subInstantiable) {
+ if (!fieldSerializable) {
// If the subtype is not instantiable do not check the arguments.
return anySubtypes;
}
@@ -1193,7 +1248,7 @@
+ "'");
Set<JTypeParameter> constBy = subParamsConstrainedBy.get(param);
if (constBy == null) {
- subInstantiable &= checkTypeArgument(paramLogger, genericSub, i,
+ fieldSerializable &= checkTypeArgument(paramLogger, genericSub, i,
param.getFirstBound(), true, path);
} else {
boolean paramOK = false;
@@ -1201,7 +1256,7 @@
paramOK |= checkTypeArgument(paramLogger, genericSub, i,
typeArgs[constrained.getOrdinal()], true, path);
}
- subInstantiable &= paramOK;
+ fieldSerializable &= paramOK;
}
}
} else {
@@ -1225,13 +1280,14 @@
+ currentSubtype.getParameterizedQualifiedSourceName()
+ "' because it is not assignable to '"
+ isParameterized.getParameterizedQualifiedSourceName() + "'");
- subInstantiable = false;
+ fieldSerializable = false;
}
}
}
}
- if (subInstantiable) {
+ if (fieldSerializable
+ && canBeInstantiated(subtypeLogger, currentSubtype, TreeLogger.DEBUG)) {
if (instSubtypes != null) {
instSubtypes.add(currentSubtype);
}
@@ -1342,12 +1398,7 @@
private boolean isAllowedByFilter(TreeLogger logger, JClassType classType,
boolean isSpeculative) {
- if (!typeFilter.isAllowed(classType)) {
- logger.log(getLogLevel(isSpeculative), "Excluded by type filter ");
- return false;
- }
-
- return true;
+ return isAllowedByFilter(logger, typeFilter, classType, isSpeculative);
}
private void logPath(TreeLogger logger, Path path) {
diff --git a/user/src/com/google/gwt/user/rebind/rpc/TypeHierarchyUtils.java b/user/src/com/google/gwt/user/rebind/rpc/TypeHierarchyUtils.java
index a2fb1e8..d1c048d 100644
--- a/user/src/com/google/gwt/user/rebind/rpc/TypeHierarchyUtils.java
+++ b/user/src/com/google/gwt/user/rebind/rpc/TypeHierarchyUtils.java
@@ -75,7 +75,12 @@
List<JClassType> immediateSubtypes = new ArrayList<JClassType>();
clazz = clazz.getErasedType();
for (JClassType subclass : clazz.getSubtypes()) {
- if (subclass.getSuperclass() == clazz || clazz.isInterface() != null
+ JClassType superclass = subclass.getSuperclass();
+ if (superclass != null) {
+ superclass = superclass.getErasedType();
+ }
+
+ if (superclass == clazz || clazz.isInterface() != null
&& directlyImplementsInterface(subclass, clazz)) {
immediateSubtypes.add(subclass);
}
diff --git a/user/src/com/google/gwt/user/rebind/rpc/TypeParameterExposureComputer.java b/user/src/com/google/gwt/user/rebind/rpc/TypeParameterExposureComputer.java
index e38f360..e107c92 100644
--- a/user/src/com/google/gwt/user/rebind/rpc/TypeParameterExposureComputer.java
+++ b/user/src/com/google/gwt/user/rebind/rpc/TypeParameterExposureComputer.java
@@ -87,25 +87,28 @@
boolean didChange = false;
JClassType type = baseType;
while (type != null) {
- JField[] fields = type.getFields();
- for (JField field : fields) {
- if (!SerializableTypeOracleBuilder.qualfiesForSerialization(
- TreeLogger.NULL, field)) {
- continue;
- }
+ if (SerializableTypeOracleBuilder.shouldConsiderFieldsForSerialization(
+ TreeLogger.NULL, type, true, typeFilter)) {
+ JField[] fields = type.getFields();
+ for (JField field : fields) {
+ if (!SerializableTypeOracleBuilder.shouldConsiderForSerialization(
+ TreeLogger.NULL, field)) {
+ continue;
+ }
- if (field.getType().getLeafType() == getTypeParameter()) {
- /*
- * If the type parameter is referenced explicitly or as the leaf
- * type of an array, then it will be considered directly exposed.
- */
- markExposedAsArray(0);
- mightNotBeExposed = false;
- didChange = true;
+ if (field.getType().getLeafType() == getTypeParameter()) {
+ /*
+ * If the type parameter is referenced explicitly or as the leaf
+ * type of an array, then it will be considered directly exposed.
+ */
+ markExposedAsArray(0);
+ mightNotBeExposed = false;
+ didChange = true;
- JArrayType fieldTypeAsArray = field.getType().isArray();
- if (fieldTypeAsArray != null) {
- markExposedAsArray(fieldTypeAsArray.getRank());
+ JArrayType fieldTypeAsArray = field.getType().isArray();
+ if (fieldTypeAsArray != null) {
+ markExposedAsArray(fieldTypeAsArray.getRank());
+ }
}
}
}
@@ -208,12 +211,13 @@
JClassType[] subtypes = baseType.getSubtypes();
for (JClassType subtype : subtypes) {
JGenericType isGeneric = subtype.isGenericType();
- if (isGeneric == null || isGeneric.isLocalType()
- || (isGeneric.isMemberType() && !isGeneric.isStatic())) {
- // Only generic types can cause a type parameter to be exposed,
- // we exclude local and non-static member types that we know cannot
- // be serialized.
- // TODO: Unify this check with the checkTypeInstantiableNoSubtypes.
+ if (isGeneric == null) {
+ // Only generic types can cause a type parameter to be exposed
+ continue;
+ }
+
+ if (!SerializableTypeOracleBuilder.shouldConsiderFieldsForSerialization(
+ TreeLogger.NULL, subtype, true, typeFilter)) {
continue;
}
@@ -229,28 +233,31 @@
JClassType type = baseType;
while (type != null) {
- JField[] fields = type.getFields();
- for (JField field : fields) {
- if (!SerializableTypeOracleBuilder.qualfiesForSerialization(
- TreeLogger.NULL, field)) {
- continue;
- }
+ if (SerializableTypeOracleBuilder.shouldConsiderFieldsForSerialization(
+ TreeLogger.NULL, type, true, typeFilter)) {
+ JField[] fields = type.getFields();
+ for (JField field : fields) {
+ if (!SerializableTypeOracleBuilder.shouldConsiderForSerialization(
+ TreeLogger.NULL, field)) {
+ continue;
+ }
- JParameterizedType isParameterized = field.getType().isParameterized();
- if (isParameterized == null) {
- continue;
- }
+ JParameterizedType isParameterized = field.getType().isParameterized();
+ if (isParameterized == null) {
+ continue;
+ }
- JClassType[] typeArgs = isParameterized.getTypeArgs();
- for (int i = 0; i < typeArgs.length; ++i) {
- if (referencesTypeParameter(typeArgs[i], getTypeParameter())) {
- JGenericType genericFieldType = isParameterized.getBaseType();
- recordCausesExposure(genericFieldType, i, 0);
- JArrayType typeArgIsArray = typeArgs[i].isArray();
- if (typeArgIsArray != null
- && typeArgIsArray.getLeafType() == getTypeParameter()) {
- int dims = typeArgIsArray.getRank();
- recordCausesExposure(genericFieldType, i, dims);
+ JClassType[] typeArgs = isParameterized.getTypeArgs();
+ for (int i = 0; i < typeArgs.length; ++i) {
+ if (referencesTypeParameter(typeArgs[i], getTypeParameter())) {
+ JGenericType genericFieldType = isParameterized.getBaseType();
+ recordCausesExposure(genericFieldType, i, 0);
+ JArrayType typeArgIsArray = typeArgs[i].isArray();
+ if (typeArgIsArray != null
+ && typeArgIsArray.getLeafType() == getTypeParameter()) {
+ int dims = typeArgIsArray.getRank();
+ recordCausesExposure(genericFieldType, i, dims);
+ }
}
}
}
@@ -327,10 +334,16 @@
}
}
+ private TypeFilter typeFilter;
+
private final Map<JTypeParameter, TypeParameterFlowInfo> typeParameterToFlowInfo = new IdentityHashMap<JTypeParameter, TypeParameterFlowInfo>();
private final Set<TypeParameterFlowInfo> worklist = new LinkedHashSet<TypeParameterFlowInfo>();
+ TypeParameterExposureComputer(TypeFilter typeFilter) {
+ this.typeFilter = typeFilter;
+ }
+
/**
* Computes flow information for the specified type parameter. If it has
* already been computed just return the value of the previous computation.
@@ -369,6 +382,10 @@
return queryFlow;
}
+ public void setTypeFilter(TypeFilter typeFilter) {
+ this.typeFilter = typeFilter;
+ }
+
/**
* Return the parameter flow info for a type parameter specified by class and
* index. If the flow info did not previously exist, create it and add it to
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 1182adf..d3e96ce 100644
--- a/user/test/com/google/gwt/user/rebind/rpc/SerializableTypeOracleBuilderTest.java
+++ b/user/test/com/google/gwt/user/rebind/rpc/SerializableTypeOracleBuilderTest.java
@@ -606,54 +606,59 @@
// Does not qualify because it is not declared to be auto or manually
// serializable
JClassType notSerializable = to.getType("NotSerializable");
- assertFalse(sob.qualifiesForSerialization(logger, notSerializable, false,
- null));
+ assertFalse(sob.shouldConsiderFieldsForSerialization(logger,
+ notSerializable, false));
// Local types should not qualify for serialization
JClassType iFoo = to.getType("AutoSerializable.IFoo");
- assertFalse(sob.qualifiesForSerialization(logger, iFoo.getSubtypes()[0],
- false, null));
+ assertFalse(sob.shouldConsiderFieldsForSerialization(logger,
+ iFoo.getSubtypes()[0], false));
// Static nested types qualify for serialization
JClassType staticNested = to.getType("OuterClass.StaticNested");
- assertTrue(sob.qualifiesForSerialization(logger, staticNested, false, null));
+ assertTrue(sob.shouldConsiderFieldsForSerialization(logger, staticNested,
+ false));
// Non-static nested types do not qualify for serialization
JClassType nonStaticNested = to.getType("OuterClass.NonStaticNested");
- assertFalse(sob.qualifiesForSerialization(logger, nonStaticNested, false,
- null));
+ assertFalse(sob.shouldConsiderFieldsForSerialization(logger,
+ nonStaticNested, false));
// Abstract classes that implement Serializable should not qualify
JClassType abstractSerializableClass = to.getType("AbstractSerializableClass");
- assertFalse(sob.qualifiesForSerialization(logger,
- abstractSerializableClass, false, null));
+ assertTrue(sob.shouldConsiderFieldsForSerialization(logger,
+ abstractSerializableClass, false));
+ assertFalse(SerializableTypeOracleBuilder.canBeInstantiated(
+ TreeLogger.NULL, abstractSerializableClass, TreeLogger.DEBUG));
// Non-default instantiable types should not qualify
JClassType nonDefaultInstantiableSerializable = to.getType("NonDefaultInstantiableSerializable");
- assertFalse(sob.qualifiesForSerialization(logger,
- nonDefaultInstantiableSerializable, false, null));
+ assertTrue(sob.shouldConsiderFieldsForSerialization(logger,
+ nonDefaultInstantiableSerializable, false));
+ assertFalse(SerializableTypeOracleBuilder.canBeInstantiated(
+ TreeLogger.NULL, nonDefaultInstantiableSerializable, TreeLogger.DEBUG));
// SPublicStaticInnerInner is not accessible to classes in its package
JClassType publicStaticInnerInner = to.getType("PublicOuterClass.PrivateStaticInner.PublicStaticInnerInner");
- assertFalse(sob.qualifiesForSerialization(logger, publicStaticInnerInner,
- false, null));
+ assertFalse(sob.shouldConsiderFieldsForSerialization(logger,
+ publicStaticInnerInner, false));
// DefaultStaticInnerInner is visible to classes in its package
JClassType defaultStaticInnerInner = to.getType("PublicOuterClass.DefaultStaticInner.DefaultStaticInnerInner");
- assertTrue(sob.qualifiesForSerialization(logger, defaultStaticInnerInner,
- false, null));
+ assertTrue(sob.shouldConsiderFieldsForSerialization(logger,
+ defaultStaticInnerInner, false));
// Enum with subclasses should qualify, but their subtypes should not
JClassType enumWithSubclasses = to.getType("EnumWithSubclasses");
- assertTrue(sob.qualifiesForSerialization(logger, enumWithSubclasses, false,
- null));
- assertFalse(sob.qualifiesForSerialization(logger,
- enumWithSubclasses.getSubtypes()[0], false, null));
+ assertTrue(sob.shouldConsiderFieldsForSerialization(logger,
+ enumWithSubclasses, false));
+ assertFalse(sob.shouldConsiderFieldsForSerialization(logger,
+ enumWithSubclasses.getSubtypes()[0], false));
// Enum that are not default instantiable should qualify
JClassType enumWithNonDefaultCtors = to.getType("EnumWithNonDefaultCtors");
- assertTrue(sob.qualifiesForSerialization(logger, enumWithNonDefaultCtors,
- false, null));
+ assertTrue(sob.shouldConsiderFieldsForSerialization(logger,
+ enumWithNonDefaultCtors, false));
}
/**