Formatting update for com/google/gwt/user/rebind/rpc/*
Review at http://gwt-code-reviews.appspot.com/1454805
Review by: zundel@google.com
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@10298 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/user/rebind/rpc/BlacklistTypeFilter.java b/user/src/com/google/gwt/user/rebind/rpc/BlacklistTypeFilter.java
index 6532eda..b05141a 100644
--- a/user/src/com/google/gwt/user/rebind/rpc/BlacklistTypeFilter.java
+++ b/user/src/com/google/gwt/user/rebind/rpc/BlacklistTypeFilter.java
@@ -34,8 +34,7 @@
* Configure {@link RegexFilter} for use for RPC blacklists.
*/
private static class RpcBlacklist extends RegexFilter {
- public RpcBlacklist(TreeLogger logger, List<String> regexes)
- throws UnableToCompleteException {
+ public RpcBlacklist(TreeLogger logger, List<String> regexes) throws UnableToCompleteException {
super(logger, regexes);
}
@@ -59,13 +58,11 @@
try {
prop = propertyOracle.getConfigurationProperty(PROP_RPC_BLACKLIST);
} catch (BadPropertyValueException e) {
- logger.log(TreeLogger.ERROR, "Could not find property "
- + PROP_RPC_BLACKLIST);
+ logger.log(TreeLogger.ERROR, "Could not find property " + PROP_RPC_BLACKLIST);
throw new UnableToCompleteException();
}
- this.logger = logger.branch(TreeLogger.DEBUG,
- "Analyzing RPC blacklist information");
+ this.logger = logger.branch(TreeLogger.DEBUG, "Analyzing RPC blacklist information");
blacklist = new RpcBlacklist(logger, prop.getValues());
}
diff --git a/user/src/com/google/gwt/user/rebind/rpc/CustomFieldSerializerValidator.java b/user/src/com/google/gwt/user/rebind/rpc/CustomFieldSerializerValidator.java
index b22d071..3d1e943 100644
--- a/user/src/com/google/gwt/user/rebind/rpc/CustomFieldSerializerValidator.java
+++ b/user/src/com/google/gwt/user/rebind/rpc/CustomFieldSerializerValidator.java
@@ -31,24 +31,27 @@
* Checks that a custom serializer is valid.
*/
public class CustomFieldSerializerValidator {
- private static final String NO_DESERIALIZE_METHOD = "Custom Field Serializer ''{0}'' does not define a deserialize method: ''public static void deserialize({1} reader,{2} instance)''";
- private static final String NO_INSTANTIATE_METHOD = "Custom Field Serializer ''{0}'' does not define an instantiate method: ''public static {1} instantiate({2} reader)''; but ''{1}'' is not default instantiable";
- private static final String NO_SERIALIZE_METHOD = "Custom Field Serializer ''{0}'' does not define a serialize method: ''public static void serialize({1} writer,{2} instance)''";
- private static final String TOO_MANY_METHODS = "Custom Field Serializer ''{0}'' defines too many methods named ''{1}''; please define only one method with that name";
- private static final String WRONG_CONCRETE_TYPE_RETURN = "Custom Field Serializer ''{0}'' returns the wrong type from ''concreteType''; return type must be ''java.lang.String''";
+ private static final String NO_DESERIALIZE_METHOD =
+ "Custom Field Serializer ''{0}'' does not define a deserialize method: ''public static void deserialize({1} reader,{2} instance)''";
+ private static final String NO_INSTANTIATE_METHOD =
+ "Custom Field Serializer ''{0}'' does not define an instantiate method: ''public static {1} instantiate({2} reader)''; but ''{1}'' is not default instantiable";
+ private static final String NO_SERIALIZE_METHOD =
+ "Custom Field Serializer ''{0}'' does not define a serialize method: ''public static void serialize({1} writer,{2} instance)''";
+ private static final String TOO_MANY_METHODS =
+ "Custom Field Serializer ''{0}'' defines too many methods named ''{1}''; please define only one method with that name";
+ private static final String WRONG_CONCRETE_TYPE_RETURN =
+ "Custom Field Serializer ''{0}'' returns the wrong type from ''concreteType''; return type must be ''java.lang.String''";
public static JMethod getConcreteTypeMethod(JClassType serializer) {
return serializer.findMethod("concreteType", new JType[0]);
}
- public static JMethod getDeserializationMethod(JClassType serializer,
- JClassType serializee) {
- return getMethod("deserialize", SerializationStreamReader.class.getName(),
- serializer, serializee);
+ public static JMethod getDeserializationMethod(JClassType serializer, JClassType serializee) {
+ return getMethod("deserialize", SerializationStreamReader.class.getName(), serializer,
+ serializee);
}
- public static JMethod getInstantiationMethod(JClassType serializer,
- JClassType serializee) {
+ public static JMethod getInstantiationMethod(JClassType serializer, JClassType serializee) {
JMethod[] overloads = serializer.getOverloads("instantiate");
for (JMethod overload : overloads) {
JParameter[] parameters = overload.getParameters();
@@ -85,24 +88,19 @@
return null;
}
- public static JMethod getSerializationMethod(JClassType serializer,
- JClassType serializee) {
- return getMethod("serialize", SerializationStreamWriter.class.getName(),
- serializer, serializee);
+ public static JMethod getSerializationMethod(JClassType serializer, JClassType serializee) {
+ return getMethod("serialize", SerializationStreamWriter.class.getName(), serializer, serializee);
}
- public static boolean hasDeserializationMethod(JClassType serializer,
- JClassType serializee) {
+ public static boolean hasDeserializationMethod(JClassType serializer, JClassType serializee) {
return getDeserializationMethod(serializer, serializee) != null;
}
- public static boolean hasInstantiationMethod(JClassType serializer,
- JClassType serializee) {
+ public static boolean hasInstantiationMethod(JClassType serializer, JClassType serializee) {
return getInstantiationMethod(serializer, serializee) != null;
}
- public static boolean hasSerializationMethod(JClassType serializer,
- JClassType serializee) {
+ public static boolean hasSerializationMethod(JClassType serializer, JClassType serializee) {
return getSerializationMethod(serializer, serializee) != null;
}
@@ -115,8 +113,7 @@
* @return list of error messages, if any, associated with the custom field
* serializer
*/
- public static List<String> validate(JClassType serializer,
- JClassType serializee) {
+ public static List<String> validate(JClassType serializer, JClassType serializee) {
List<String> reasons = new ArrayList<String>();
if (serializee.isEnum() != null) {
@@ -131,20 +128,16 @@
if (!hasDeserializationMethod(serializer, serializee)) {
// No valid deserialize method was found.
- reasons.add(MessageFormat.format(NO_DESERIALIZE_METHOD,
- serializer.getQualifiedSourceName(),
- SerializationStreamReader.class.getName(),
- serializee.getQualifiedSourceName()));
+ reasons.add(MessageFormat.format(NO_DESERIALIZE_METHOD, serializer.getQualifiedSourceName(),
+ SerializationStreamReader.class.getName(), serializee.getQualifiedSourceName()));
} else {
checkTooMany("deserialize", serializer, reasons);
}
if (!hasSerializationMethod(serializer, serializee)) {
// No valid serialize method was found.
- reasons.add(MessageFormat.format(NO_SERIALIZE_METHOD,
- serializer.getQualifiedSourceName(),
- SerializationStreamWriter.class.getName(),
- serializee.getQualifiedSourceName()));
+ reasons.add(MessageFormat.format(NO_SERIALIZE_METHOD, serializer.getQualifiedSourceName(),
+ SerializationStreamWriter.class.getName(), serializee.getQualifiedSourceName()));
} else {
checkTooMany("serialize", serializer, reasons);
}
@@ -153,8 +146,7 @@
if (!serializee.isDefaultInstantiable() && !serializee.isAbstract()) {
// Not default instantiable and no instantiate method was found.
reasons.add(MessageFormat.format(NO_INSTANTIATE_METHOD,
- serializer.getQualifiedSourceName(),
- serializee.getQualifiedSourceName(),
+ serializer.getQualifiedSourceName(), serializee.getQualifiedSourceName(),
SerializationStreamReader.class.getName()));
}
} else {
@@ -165,8 +157,8 @@
if (concreteTypeMethod != null) {
if (!"java.lang.String".equals(concreteTypeMethod.getReturnType().getQualifiedSourceName())) {
// Wrong return type.
- reasons.add(MessageFormat.format(WRONG_CONCRETE_TYPE_RETURN,
- serializer.getQualifiedSourceName()));
+ reasons.add(MessageFormat.format(WRONG_CONCRETE_TYPE_RETURN, serializer
+ .getQualifiedSourceName()));
} else {
checkTooMany("concreteType", serializer, reasons);
}
@@ -175,12 +167,11 @@
return reasons;
}
- private static void checkTooMany(String methodName, JClassType serializer,
- List<String> reasons) {
+ private static void checkTooMany(String methodName, JClassType serializer, List<String> reasons) {
JMethod[] overloads = serializer.getOverloads(methodName);
if (overloads.length > 1) {
- reasons.add(MessageFormat.format(TOO_MANY_METHODS,
- serializer.getQualifiedSourceName(), methodName));
+ reasons.add(MessageFormat.format(TOO_MANY_METHODS, serializer.getQualifiedSourceName(),
+ methodName));
}
}
@@ -195,8 +186,7 @@
continue;
}
- if (!parameters[0].getType().getQualifiedSourceName().equals(
- streamClassName)) {
+ if (!parameters[0].getType().getQualifiedSourceName().equals(streamClassName)) {
// First param is not a stream class
continue;
}
diff --git a/user/src/com/google/gwt/user/rebind/rpc/FieldSerializerCreator.java b/user/src/com/google/gwt/user/rebind/rpc/FieldSerializerCreator.java
index 8396cf4..2834667 100644
--- a/user/src/com/google/gwt/user/rebind/rpc/FieldSerializerCreator.java
+++ b/user/src/com/google/gwt/user/rebind/rpc/FieldSerializerCreator.java
@@ -53,17 +53,18 @@
*/
public class FieldSerializerCreator {
- /* NB: FieldSerializerCreator generates two different sets of code for
- * DevMode and ProdMode. In ProdMode, the generated code uses the JSNI
- * violator pattern to access private class members. In DevMode, the generated
- * code uses ReflectionHelper instead of JSNI to avoid the many JSNI
- * boundary-crossings which are slow in DevMode.
+ /*
+ * NB: FieldSerializerCreator generates two different sets of code for DevMode
+ * and ProdMode. In ProdMode, the generated code uses the JSNI violator
+ * pattern to access private class members. In DevMode, the generated code
+ * uses ReflectionHelper instead of JSNI to avoid the many JSNI
+ * boundary-crossings which are slow in DevMode.
*/
-
+
private static final String WEAK_MAPPING_CLASS_NAME = WeakMapping.class.getName();
private final GeneratorContextExt context;
-
+
private final JClassType customFieldSerializer;
private final boolean customFieldSerializerHasInstantiate;
@@ -75,9 +76,9 @@
private final boolean isProd;
private final String methodEnd;
-
+
private final String methodStart;
-
+
private final JClassType serializableClass;
private final JField[] serializableFields;
@@ -94,35 +95,37 @@
* Constructs a field serializer for the class.
*/
public FieldSerializerCreator(GeneratorContextExt context,
- SerializableTypeOracle typesSentFromBrowser,
- SerializableTypeOracle typesSentToBrowser, JClassType requestedClass,
- JClassType customFieldSerializer) {
+ SerializableTypeOracle typesSentFromBrowser, SerializableTypeOracle typesSentToBrowser,
+ JClassType requestedClass, JClassType customFieldSerializer) {
this.context = context;
this.isProd = context.isProdMode();
- methodStart = isProd ? "/*-{" : "{";
+ methodStart = isProd ? "/*-{" : "{";
methodEnd = isProd ? "}-*/;" : "}";
this.customFieldSerializer = customFieldSerializer;
assert (requestedClass != null);
assert (requestedClass.isClass() != null || requestedClass.isArray() != null);
- this.typeOracle = context.getTypeOracle();
+ this.typeOracle = context.getTypeOracle();
this.typesSentFromBrowser = typesSentFromBrowser;
this.typesSentToBrowser = typesSentToBrowser;
serializableClass = requestedClass;
- serializableFields = SerializationUtils.getSerializableFields(typeOracle,
- requestedClass);
+ serializableFields = SerializationUtils.getSerializableFields(typeOracle, requestedClass);
this.fieldSerializerName = SerializationUtils.getStandardSerializerName(serializableClass);
- this.isJRE = SerializableTypeOracleBuilder.isInStandardJavaPackage(serializableClass.getQualifiedSourceName());
- this.customFieldSerializerHasInstantiate = (customFieldSerializer != null && CustomFieldSerializerValidator.hasInstantiationMethod(
- customFieldSerializer, serializableClass));
+ this.isJRE =
+ SerializableTypeOracleBuilder.isInStandardJavaPackage(serializableClass
+ .getQualifiedSourceName());
+ this.customFieldSerializerHasInstantiate =
+ (customFieldSerializer != null && CustomFieldSerializerValidator.hasInstantiationMethod(
+ customFieldSerializer, serializableClass));
}
public String realize(TreeLogger logger, GeneratorContext ctx) {
assert (ctx != null);
- assert (typesSentFromBrowser.isSerializable(serializableClass) || typesSentToBrowser.isSerializable(serializableClass));
+ assert (typesSentFromBrowser.isSerializable(serializableClass) || typesSentToBrowser
+ .isSerializable(serializableClass));
- logger = logger.branch(TreeLogger.DEBUG,
- "Generating a field serializer for type '"
+ logger =
+ logger.branch(TreeLogger.DEBUG, "Generating a field serializer for type '"
+ serializableClass.getQualifiedSourceName() + "'", null);
sourceWriter = getSourceWriter(logger, ctx);
@@ -179,8 +182,8 @@
}
/**
- * Returns the depth of the given class in the class hierarchy
- * (where the depth of java.lang.Object == 0).
+ * Returns the depth of the given class in the class hierarchy (where the
+ * depth of java.lang.Object == 0).
*/
private int getDepth(JClassType clazz) {
int depth = 0;
@@ -207,8 +210,8 @@
return null;
}
- ClassSourceFileComposerFactory composerFactory = new ClassSourceFileComposerFactory(
- packageName, className);
+ ClassSourceFileComposerFactory composerFactory =
+ new ClassSourceFileComposerFactory(packageName, className);
composerFactory.addImport(SerializationException.class.getCanonicalName());
composerFactory.addImport(SerializationStreamReader.class.getCanonicalName());
composerFactory.addImport(SerializationStreamWriter.class.getCanonicalName());
@@ -322,34 +325,33 @@
boolean useViolator = false;
boolean isAccessible = true;
if (isEnum == null && isClass != null) {
- isAccessible = classIsAccessible() && ctorIsAccessible();
+ isAccessible = classIsAccessible() && ctorIsAccessible();
useViolator = !isAccessible && isProd;
}
sourceWriter.print("public static" + (useViolator ? " native " : " "));
String qualifiedSourceName = serializableClass.getQualifiedSourceName();
sourceWriter.print(qualifiedSourceName);
- sourceWriter.println(" instantiate(SerializationStreamReader streamReader) throws SerializationException "
- + (useViolator ? "/*-{" : "{"));
+ sourceWriter
+ .println(" instantiate(SerializationStreamReader streamReader) throws SerializationException "
+ + (useViolator ? "/*-{" : "{"));
sourceWriter.indent();
if (isArray != null) {
sourceWriter.println("int size = streamReader.readInt();");
- sourceWriter.println("return "
- + createArrayInstantiationExpression(isArray) + ";");
+ sourceWriter.println("return " + createArrayInstantiationExpression(isArray) + ";");
} else if (isEnum != null) {
sourceWriter.println("int ordinal = streamReader.readInt();");
- sourceWriter.println(qualifiedSourceName + "[] values = "
- + qualifiedSourceName + ".values();");
+ sourceWriter.println(qualifiedSourceName + "[] values = " + qualifiedSourceName
+ + ".values();");
sourceWriter.println("assert (ordinal >= 0 && ordinal < values.length);");
sourceWriter.println("return values[ordinal];");
} else if (!isAccessible) {
if (isProd) {
sourceWriter.println("return @" + qualifiedSourceName + "::new()();");
} else {
- sourceWriter.println(
- "return ReflectionHelper.newInstance(" + qualifiedSourceName
- + ".class);");
+ sourceWriter.println("return ReflectionHelper.newInstance(" + qualifiedSourceName
+ + ".class);");
}
} else {
sourceWriter.println("return new " + qualifiedSourceName + "();");
@@ -388,17 +390,18 @@
}
// Create method
- sourceWriter.println("public Object create(SerializationStreamReader reader) throws SerializationException {");
+ sourceWriter
+ .println("public Object create(SerializationStreamReader reader) throws SerializationException {");
sourceWriter.indent();
- if (serializableClass.isEnum() != null
- || serializableClass.isDefaultInstantiable()
+ if (serializableClass.isEnum() != null || serializableClass.isDefaultInstantiable()
|| customFieldSerializerHasInstantiate) {
sourceWriter.print("return ");
String typeSig;
if (customFieldSerializer != null && customFieldSerializerHasInstantiate) {
sourceWriter.print(customFieldSerializer.getQualifiedSourceName());
- JMethod instantiationMethod = CustomFieldSerializerValidator.getInstantiationMethod(
- customFieldSerializer, serializableClass);
+ JMethod instantiationMethod =
+ CustomFieldSerializerValidator.getInstantiationMethod(customFieldSerializer,
+ serializableClass);
typeSig = getTypeSig(instantiationMethod);
} else {
sourceWriter.print(fieldSerializerName);
@@ -414,15 +417,16 @@
sourceWriter.println();
// Deserial method
- sourceWriter.println("public void deserial(SerializationStreamReader reader, Object object) throws SerializationException {");
+ sourceWriter
+ .println("public void deserial(SerializationStreamReader reader, Object object) throws SerializationException {");
if (customFieldSerializer != null) {
- JMethod deserializationMethod = CustomFieldSerializerValidator.getDeserializationMethod(
- customFieldSerializer, serializableClass);
+ JMethod deserializationMethod =
+ CustomFieldSerializerValidator.getDeserializationMethod(customFieldSerializer,
+ serializableClass);
JType castType = deserializationMethod.getParameters()[1].getType();
String typeSig = getTypeSig(deserializationMethod);
- sourceWriter.indentln(customFieldSerializer.getQualifiedSourceName()
- + "." + typeSig + "deserialize(reader, ("
- + castType.getQualifiedSourceName() + ")object);");
+ sourceWriter.indentln(customFieldSerializer.getQualifiedSourceName() + "." + typeSig
+ + "deserialize(reader, (" + castType.getQualifiedSourceName() + ")object);");
} else {
sourceWriter.indentln(fieldSerializerName + ".deserialize(reader, ("
+ serializableClass.getQualifiedSourceName() + ")object);");
@@ -431,15 +435,16 @@
sourceWriter.println();
// Serial method
- sourceWriter.println("public void serial(SerializationStreamWriter writer, Object object) throws SerializationException {");
+ sourceWriter
+ .println("public void serial(SerializationStreamWriter writer, Object object) throws SerializationException {");
if (customFieldSerializer != null) {
- JMethod serializationMethod = CustomFieldSerializerValidator.getSerializationMethod(
- customFieldSerializer, serializableClass);
+ JMethod serializationMethod =
+ CustomFieldSerializerValidator.getSerializationMethod(customFieldSerializer,
+ serializableClass);
JType castType = serializationMethod.getParameters()[1].getType();
String typeSig = getTypeSig(serializationMethod);
- sourceWriter.indentln(customFieldSerializer.getQualifiedSourceName()
- + "." + typeSig + "serialize(writer, ("
- + castType.getQualifiedSourceName() + ")object);");
+ sourceWriter.indentln(customFieldSerializer.getQualifiedSourceName() + "." + typeSig
+ + "serialize(writer, (" + castType.getQualifiedSourceName() + ")object);");
} else {
sourceWriter.indentln(fieldSerializerName + ".serialize(writer, ("
+ serializableClass.getQualifiedSourceName() + ")object);");
@@ -472,8 +477,7 @@
* Non-default instantiable classes cannot have instantiate methods.
*/
private boolean needsTypeHandler() {
- return serializableClass.isEnum() != null
- || !serializableClass.isAbstract();
+ return serializableClass.isEnum() != null || !serializableClass.isAbstract();
}
private void writeArrayDeserializationStatements(JArrayType isArray) {
@@ -517,13 +521,12 @@
private void writeClassDeserializationStatements() {
/**
* If the type is capable of making a round trip between the client and
- * server, store additional server-only field data using {@link WeakMapping}.
+ * server, store additional server-only field data using {@link WeakMapping}
+ * .
*/
if (serializableClass.isEnhanced()) {
- sourceWriter.println(WEAK_MAPPING_CLASS_NAME + ".set(instance, "
- + "\"server-enhanced-data-"
- + getDepth(serializableClass)
- + "\", streamReader.readString());");
+ sourceWriter.println(WEAK_MAPPING_CLASS_NAME + ".set(instance, " + "\"server-enhanced-data-"
+ + getDepth(serializableClass) + "\", streamReader.readString());");
}
for (JField serializableField : serializableFields) {
@@ -532,8 +535,8 @@
String readMethodName = Shared.getStreamReadMethodNameFor(fieldType);
String streamReadExpression = "streamReader." + readMethodName + "()";
if (Shared.typeNeedsCast(fieldType)) {
- streamReadExpression = "(" + fieldType.getQualifiedSourceName() + ") "
- + streamReadExpression;
+ streamReadExpression =
+ "(" + fieldType.getQualifiedSourceName() + ") " + streamReadExpression;
}
if (needsAccessorMethods(serializableField)) {
@@ -555,9 +558,10 @@
JClassType superClass = serializableClass.getSuperclass();
if (superClass != null
- && (typesSentFromBrowser.isSerializable(superClass) || typesSentToBrowser.isSerializable(superClass))) {
- String superFieldSerializer = SerializationUtils.getFieldSerializerName(
- typeOracle, superClass);
+ && (typesSentFromBrowser.isSerializable(superClass) || typesSentToBrowser
+ .isSerializable(superClass))) {
+ String superFieldSerializer =
+ SerializationUtils.getFieldSerializerName(typeOracle, superClass);
sourceWriter.print(superFieldSerializer);
sourceWriter.println(".deserialize(streamReader, instance);");
}
@@ -566,14 +570,13 @@
private void writeClassSerializationStatements() {
/**
* If the type is capable of making a round trip between the client and
- * server, retrieve the additional server-only field data from {@link WeakMapping}.
+ * server, retrieve the additional server-only field data from
+ * {@link WeakMapping}.
*/
if (serializableClass.isEnhanced()) {
- sourceWriter.println("streamWriter.writeString((String) "
- + WEAK_MAPPING_CLASS_NAME
- + ".get(instance, \"server-enhanced-data-"
- + getDepth(serializableClass) + "\"));");
+ sourceWriter.println("streamWriter.writeString((String) " + WEAK_MAPPING_CLASS_NAME
+ + ".get(instance, \"server-enhanced-data-" + getDepth(serializableClass) + "\"));");
}
for (JField serializableField : serializableFields) {
@@ -599,9 +602,10 @@
JClassType superClass = serializableClass.getSuperclass();
if (superClass != null
- && (typesSentFromBrowser.isSerializable(superClass) || typesSentToBrowser.isSerializable(superClass))) {
- String superFieldSerializer = SerializationUtils.getFieldSerializerName(
- typeOracle, superClass);
+ && (typesSentFromBrowser.isSerializable(superClass) || typesSentToBrowser
+ .isSerializable(superClass))) {
+ String superFieldSerializer =
+ SerializationUtils.getFieldSerializerName(typeOracle, superClass);
sourceWriter.print(superFieldSerializer);
sourceWriter.println(".serialize(streamWriter, instance);");
}
@@ -668,15 +672,15 @@
String fieldName = serializableField.getName();
maybeSuppressLongWarnings(fieldType);
- sourceWriter.print("private static " + (isProd ? "native " : ""));
+ sourceWriter.print("private static " + (isProd ? "native " : ""));
sourceWriter.print(fieldTypeQualifiedSourceName);
sourceWriter.print(" get");
sourceWriter.print(Shared.capitalize(fieldName));
sourceWriter.print("(");
sourceWriter.print(serializableClassQualifedName);
- sourceWriter.print(" instance) ");
+ sourceWriter.print(" instance) ");
sourceWriter.println(methodStart);
-
+
sourceWriter.indent();
if (context.isProdMode()) {
@@ -691,11 +695,10 @@
if (primType != null) {
sourceWriter.print("(" + primType.getQualifiedBoxedSourceName() + ") ");
} else {
- sourceWriter.print("(" + fieldTypeQualifiedSourceName + ") ");
+ sourceWriter.print("(" + fieldTypeQualifiedSourceName + ") ");
}
- sourceWriter.println(
- "ReflectionHelper.getField(" + serializableClassQualifedName
- + ".class, instance, \"" + fieldName + "\");");
+ sourceWriter.println("ReflectionHelper.getField(" + serializableClassQualifedName
+ + ".class, instance, \"" + fieldName + "\");");
}
sourceWriter.outdent();
@@ -722,7 +725,7 @@
sourceWriter.print(fieldTypeQualifiedSourceName);
sourceWriter.println(" value) ");
sourceWriter.println(methodStart);
-
+
sourceWriter.indent();
if (context.isProdMode()) {
@@ -732,9 +735,8 @@
sourceWriter.print(fieldName);
sourceWriter.println(" = value;");
} else {
- sourceWriter.println(
- "ReflectionHelper.setField(" + serializableClassQualifedName
- + ".class, instance, \"" + fieldName + "\", value);");
+ sourceWriter.println("ReflectionHelper.setField(" + serializableClassQualifedName
+ + ".class, instance, \"" + fieldName + "\", value);");
}
sourceWriter.outdent();
diff --git a/user/src/com/google/gwt/user/rebind/rpc/JModTypeVisitor.java b/user/src/com/google/gwt/user/rebind/rpc/JModTypeVisitor.java
index 9ebeabe..d4fc52e 100644
--- a/user/src/com/google/gwt/user/rebind/rpc/JModTypeVisitor.java
+++ b/user/src/com/google/gwt/user/rebind/rpc/JModTypeVisitor.java
@@ -28,9 +28,9 @@
/**
* <p>
* This visitor supports transforming interior parts of a type. Subclasses
- * should override the appropriate <code>endVisit</code> methods and, when
- * such a method wants to replace its argument, assign the replacement to the
- * field {@link #replacement}.
+ * should override the appropriate <code>endVisit</code> methods and, when such
+ * a method wants to replace its argument, assign the replacement to the field
+ * {@link #replacement}.
* </p>
*
* <p>
@@ -79,8 +79,8 @@
}
/**
- * Do the same thing as {@link JTypeVisitor#acceptChildren(JType)}, but if
- * any children types are replaced, reconstruct a version of <code>type</code>
+ * Do the same thing as {@link JTypeVisitor#acceptChildren(JType)}, but if any
+ * children types are replaced, reconstruct a version of <code>type</code>
* that has those corresponding replacements made and assign the new type to
* {@link #replacement}.
*/
@@ -104,8 +104,7 @@
JGenericType newBaseType = transform(oldBaseType);
JClassType oldEnclosingType = typeParameterized.getEnclosingType();
- JClassType newEnclosingType = oldEnclosingType == null ? null
- : transform(oldEnclosingType);
+ JClassType newEnclosingType = oldEnclosingType == null ? null : transform(oldEnclosingType);
JClassType[] oldTypeArgs = typeParameterized.getTypeArgs();
JClassType[] newTypeArgs = new JClassType[oldTypeArgs.length];
@@ -117,12 +116,12 @@
}
}
- if (argsAllSame && oldBaseType == newBaseType
- && oldEnclosingType == newEnclosingType) {
+ if (argsAllSame && oldBaseType == newBaseType && oldEnclosingType == newEnclosingType) {
replacement = type;
} else {
- replacement = typeParameterized.getOracle().getParameterizedType(
- newBaseType, newEnclosingType, newTypeArgs);
+ replacement =
+ typeParameterized.getOracle().getParameterizedType(newBaseType, newEnclosingType,
+ newTypeArgs);
}
}
@@ -146,8 +145,7 @@
if (oldBound == newBound) {
replacement = type;
} else {
- replacement = typeWild.getOracle().getWildcardType(
- typeWild.getBoundType(), newBound);
+ replacement = typeWild.getOracle().getWildcardType(typeWild.getBoundType(), newBound);
}
}
}
diff --git a/user/src/com/google/gwt/user/rebind/rpc/JTypeVisitor.java b/user/src/com/google/gwt/user/rebind/rpc/JTypeVisitor.java
index 5d746e3..b75be78 100644
--- a/user/src/com/google/gwt/user/rebind/rpc/JTypeVisitor.java
+++ b/user/src/com/google/gwt/user/rebind/rpc/JTypeVisitor.java
@@ -44,8 +44,8 @@
}
/**
- * Call {@link #accept(JType)} on all children types of <code>type</code>.
- * The children type of a type are its structural components. For example, an
+ * Call {@link #accept(JType)} on all children types of <code>type</code>. The
+ * children type of a type are its structural components. For example, an
* array type has one child, which is the component type of the array.
*/
protected void acceptChildren(JType type) {
diff --git a/user/src/com/google/gwt/user/rebind/rpc/ProblemReport.java b/user/src/com/google/gwt/user/rebind/rpc/ProblemReport.java
index c256636..f5bc666 100644
--- a/user/src/com/google/gwt/user/rebind/rpc/ProblemReport.java
+++ b/user/src/com/google/gwt/user/rebind/rpc/ProblemReport.java
@@ -1,12 +1,12 @@
/*
* Copyright 2008 Google Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -33,20 +33,22 @@
public class ProblemReport {
/**
- * Priority of problems. {@link #FATAL} problems will fail a build that
- * would otherwise have succeeded, for example because of a bad custom
- * serializer used only as a subclass of a superclass with other viable
- * subtypes. {@link #DEFAULT} problems might or might not be fatal,
- * depending on overall results accumulated later. {@link #AUXILIARY}
- * problems are not fatal, and often not even problems by themselves, but
- * diagnostics related to default problems (e.g. type filtration, which
- * might suppress an intended-to-serialize class).
+ * Priority of problems. {@link #FATAL} problems will fail a build that would
+ * otherwise have succeeded, for example because of a bad custom serializer
+ * used only as a subclass of a superclass with other viable subtypes.
+ * {@link #DEFAULT} problems might or might not be fatal, depending on overall
+ * results accumulated later. {@link #AUXILIARY} problems are not fatal, and
+ * often not even problems by themselves, but diagnostics related to default
+ * problems (e.g. type filtration, which might suppress an
+ * intended-to-serialize class).
*/
- public enum Priority { FATAL, DEFAULT, AUXILIARY}
+ public enum Priority {
+ FATAL, DEFAULT, AUXILIARY
+ }
/**
- * An individual report, which may require multiple entries (expressed as
- * logs under a branchpoint), but relates to an individual issue.
+ * An individual report, which may require multiple entries (expressed as logs
+ * under a branchpoint), but relates to an individual issue.
*/
public static class Problem {
private String message;
@@ -88,13 +90,13 @@
*/
public ProblemReport() {
Comparator<JClassType> comparator = new Comparator<JClassType>() {
- public int compare(JClassType o1, JClassType o2) {
- assert o1 != null;
- assert o2 != null;
- return o1.getParameterizedQualifiedSourceName().compareTo(
- o2.getParameterizedQualifiedSourceName());
- }
- };
+ public int compare(JClassType o1, JClassType o2) {
+ assert o1 != null;
+ assert o2 != null;
+ return o1.getParameterizedQualifiedSourceName().compareTo(
+ o2.getParameterizedQualifiedSourceName());
+ }
+ };
allProblems = new TreeMap<JClassType, List<Problem>>(comparator);
auxiliaries = new TreeMap<JClassType, List<Problem>>(comparator);
fatalProblems = new TreeMap<JClassType, List<Problem>>(comparator);
@@ -102,21 +104,19 @@
}
/**
- * Adds a problem for a given type. This also sorts the problems into
+ * Adds a problem for a given type. This also sorts the problems into
* collections by priority.
- *
+ *
* @param type the problematic type
* @param message the description of the problem
* @param priority priority of the problem.
* @param extraLines additional continuation lines for the message, usually
- * for additional explanations.
+ * for additional explanations.
*/
- public Problem add(JClassType type, String message, Priority priority,
- String... extraLines) {
+ public Problem add(JClassType type, String message, Priority priority, String... extraLines) {
String contextString = "";
if (contextType != null) {
- contextString = " (reached via " +
- contextType.getParameterizedQualifiedSourceName() + ")";
+ contextString = " (reached via " + contextType.getParameterizedQualifiedSourceName() + ")";
}
message = message + contextString;
Problem entry = new Problem(message, extraLines);
@@ -157,25 +157,23 @@
}
/**
- * Reports all problems to the logger supplied, at the log level supplied.
- * The problems are assured of being reported in lexographic order of
- * type names.
- *
+ * Reports all problems to the logger supplied, at the log level supplied. The
+ * problems are assured of being reported in lexographic order of type names.
+ *
* @param logger logger to receive problem reports
* @param problemLevel severity level at which to report problems.
* @param auxLevel severity level at which to report any auxiliary messages.
*/
- public void report(TreeLogger logger, TreeLogger.Type problemLevel,
- TreeLogger.Type auxLevel) {
+ public void report(TreeLogger logger, TreeLogger.Type problemLevel, TreeLogger.Type auxLevel) {
doReport(logger, auxLevel, auxiliaries);
doReport(logger, problemLevel, allProblems);
}
/**
* Reports only urgent problems to the logger supplied, at the log level
- * supplied. The problems are assured of being reported in lexographic
- * order of type names.
- *
+ * supplied. The problems are assured of being reported in lexographic order
+ * of type names.
+ *
* @param logger logger to receive problem reports
* @param level severity level at which to report problems.
*/
@@ -184,10 +182,10 @@
}
/**
- * Sets the context type currently being analyzed. Problems found will
- * include reference to this context, until reset with another call to this
- * method. Context may be canceled with a {@code null} value here.
- *
+ * Sets the context type currently being analyzed. Problems found will include
+ * reference to this context, until reset with another call to this method.
+ * Context may be canceled with a {@code null} value here.
+ *
* @param newContext the type under analysis
*/
public void setContextType(JClassType newContext) {
@@ -195,13 +193,13 @@
}
/**
- * Test accessor returning list of auxiliary "problems" logged against a
- * given type.
- *
+ * Test accessor returning list of auxiliary "problems" logged against a given
+ * type.
+ *
* @param type type to fetch problems for
- * @return {@code null} if no auxiliaries were logged. Otherwise, a list
- * of strings describing messages, including the context in which the
- * problem was found.
+ * @return {@code null} if no auxiliaries were logged. Otherwise, a list of
+ * strings describing messages, including the context in which the
+ * problem was found.
*/
List<Problem> getAuxiliaryMessagesForType(JClassType type) {
List<Problem> list = auxiliaries.get(type);
@@ -213,11 +211,11 @@
/**
* Test accessor returning list of problems logged against a given type.
- *
+ *
* @param type type to fetch problems for
- * @return {@code null} if no problems were logged. Otherwise, a list
- * of strings describing problems, including the context in which the
- * problem was found.
+ * @return {@code null} if no problems were logged. Otherwise, a list of
+ * strings describing problems, including the context in which the
+ * problem was found.
*/
List<Problem> getProblemsForType(JClassType type) {
List<Problem> list = allProblems.get(type);
@@ -229,13 +227,12 @@
/**
* Adds an entry to one of the problem maps.
- *
+ *
* @param type the type to add
* @param message the message to add for {@code type}
* @param map the map to add to
*/
- private void addToMap(JClassType type, Problem problem,
- Map<JClassType, List<Problem>> map) {
+ private void addToMap(JClassType type, Problem problem, Map<JClassType, List<Problem>> map) {
List<Problem> list = map.get(type);
if (list == null) {
list = new ArrayList<Problem>();
@@ -246,13 +243,12 @@
/**
* Logs all of the problems from one of the problem maps.
- *
+ *
* @param logger the logger to log to
* @param level the level for messages
* @param problems the problems to log
*/
- private void doReport(TreeLogger logger, Type level,
- Map<JClassType, List<Problem>> problems) {
+ private void doReport(TreeLogger logger, Type level, Map<JClassType, List<Problem>> problems) {
if (!logger.isLoggable(level)) {
return;
}
diff --git a/user/src/com/google/gwt/user/rebind/rpc/ProxyCreator.java b/user/src/com/google/gwt/user/rebind/rpc/ProxyCreator.java
index baf3e58..8b1d349 100644
--- a/user/src/com/google/gwt/user/rebind/rpc/ProxyCreator.java
+++ b/user/src/com/google/gwt/user/rebind/rpc/ProxyCreator.java
@@ -1,12 +1,12 @@
/*
* Copyright 2008 Google Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -87,7 +87,8 @@
*/
public static final String MANIFEST_ARTIFACT_DIR = "rpcPolicyManifest/manifests";
- private static final Map<JPrimitiveType, ResponseReader> JPRIMITIVETYPE_TO_RESPONSEREADER = new HashMap<JPrimitiveType, ResponseReader>();
+ private static final Map<JPrimitiveType, ResponseReader> JPRIMITIVETYPE_TO_RESPONSEREADER =
+ new HashMap<JPrimitiveType, ResponseReader>();
private static final String PROXY_SUFFIX = "_Proxy";
@@ -95,14 +96,14 @@
* Adds a root type for each type that appears in the RemoteService interface
* methods.
*/
- private static void addRemoteServiceRootTypes(TreeLogger logger,
- TypeOracle typeOracle,
+ private static void addRemoteServiceRootTypes(TreeLogger logger, TypeOracle typeOracle,
SerializableTypeOracleBuilder typesSentFromBrowser,
SerializableTypeOracleBuilder typesSentToBrowser, JClassType remoteService)
throws NotFoundException, UnableToCompleteException {
- logger = logger.branch(TreeLogger.DEBUG, "Analyzing '"
- + remoteService.getParameterizedQualifiedSourceName()
- + "' for serializable types", null);
+ logger =
+ logger.branch(TreeLogger.DEBUG, "Analyzing '"
+ + remoteService.getParameterizedQualifiedSourceName() + "' for serializable types",
+ null);
JMethod[] methods = remoteService.getOverridableMethods();
@@ -111,8 +112,7 @@
JClassType rteType = typeOracle.getType(RpcTokenException.class.getName());
JClassType rpcTokenClass = typeOracle.getType(RpcToken.class.getName());
RpcTokenImplementation tokenClassToUse =
- remoteService.findAnnotationInTypeHierarchy(
- RpcTokenImplementation.class);
+ remoteService.findAnnotationInTypeHierarchy(RpcTokenImplementation.class);
if (tokenClassToUse != null) {
// only include serializer for the specified class literal
JClassType rpcTokenType = typeOracle.getType(tokenClassToUse.value());
@@ -120,9 +120,8 @@
typesSentFromBrowser.addRootType(logger, rpcTokenType);
typesSentToBrowser.addRootType(logger, rteType);
} else {
- logger.branch(TreeLogger.ERROR,
- "RPC token class " + tokenClassToUse.value() + " must implement " +
- RpcToken.class.getName(), null);
+ logger.branch(TreeLogger.ERROR, "RPC token class " + tokenClassToUse.value()
+ + " must implement " + RpcToken.class.getName(), null);
throw new UnableToCompleteException();
}
} else {
@@ -135,39 +134,33 @@
}
}
- TreeLogger validationLogger = logger.branch(TreeLogger.DEBUG,
- "Analyzing methods:", null);
+ TreeLogger validationLogger = logger.branch(TreeLogger.DEBUG, "Analyzing methods:", null);
for (JMethod method : methods) {
- TreeLogger methodLogger = validationLogger.branch(TreeLogger.DEBUG,
- method.toString(), null);
+ TreeLogger methodLogger = validationLogger.branch(TreeLogger.DEBUG, method.toString(), null);
JType returnType = method.getReturnType();
if (returnType != JPrimitiveType.VOID) {
- TreeLogger returnTypeLogger = methodLogger.branch(TreeLogger.DEBUG,
- "Return type: " + returnType.getParameterizedQualifiedSourceName(),
- null);
+ TreeLogger returnTypeLogger =
+ methodLogger.branch(TreeLogger.DEBUG, "Return type: "
+ + returnType.getParameterizedQualifiedSourceName(), null);
typesSentToBrowser.addRootType(returnTypeLogger, returnType);
}
JParameter[] params = method.getParameters();
for (JParameter param : params) {
- TreeLogger paramLogger = methodLogger.branch(TreeLogger.DEBUG,
- "Parameter: " + param.toString(), null);
+ TreeLogger paramLogger =
+ methodLogger.branch(TreeLogger.DEBUG, "Parameter: " + param.toString(), null);
JType paramType = param.getType();
typesSentFromBrowser.addRootType(paramLogger, paramType);
}
JType[] exs = method.getThrows();
if (exs.length > 0) {
- TreeLogger throwsLogger = methodLogger.branch(TreeLogger.DEBUG,
- "Throws:", null);
+ TreeLogger throwsLogger = methodLogger.branch(TreeLogger.DEBUG, "Throws:", null);
for (JType ex : exs) {
if (!exceptionClass.isAssignableFrom(ex.isClass())) {
- throwsLogger = throwsLogger.branch(
- TreeLogger.WARN,
- "'"
- + ex.getQualifiedSourceName()
- + "' is not a checked exception; only checked exceptions may be used",
- null);
+ throwsLogger =
+ throwsLogger.branch(TreeLogger.WARN, "'" + ex.getQualifiedSourceName()
+ + "' is not a checked exception; only checked exceptions may be used", null);
}
typesSentToBrowser.addRootType(throwsLogger, ex);
@@ -180,9 +173,8 @@
* Add the implicit root types that are needed to make RPC work. These would
* be {@link String} and {@link IncompatibleRemoteServiceException}.
*/
- private static void addRequiredRoots(TreeLogger logger,
- TypeOracle typeOracle, SerializableTypeOracleBuilder stob)
- throws NotFoundException {
+ private static void addRequiredRoots(TreeLogger logger, TypeOracle typeOracle,
+ SerializableTypeOracleBuilder stob) throws NotFoundException {
logger = logger.branch(TreeLogger.DEBUG, "Analyzing implicit types");
// String is always instantiable.
@@ -204,8 +196,7 @@
typesList.addAll(Arrays.asList(a));
}
JType[] serializableTypes = typesList.toArray(new JType[0]);
- Arrays.sort(serializableTypes,
- SerializableTypeOracleBuilder.JTYPE_COMPARATOR);
+ Arrays.sort(serializableTypes, SerializableTypeOracleBuilder.JTYPE_COMPARATOR);
return serializableTypes;
}
@@ -219,23 +210,15 @@
private Map<JType, String> typeStrings;
{
- JPRIMITIVETYPE_TO_RESPONSEREADER.put(JPrimitiveType.BOOLEAN,
- ResponseReader.BOOLEAN);
- JPRIMITIVETYPE_TO_RESPONSEREADER.put(JPrimitiveType.BYTE,
- ResponseReader.BYTE);
- JPRIMITIVETYPE_TO_RESPONSEREADER.put(JPrimitiveType.CHAR,
- ResponseReader.CHAR);
- JPRIMITIVETYPE_TO_RESPONSEREADER.put(JPrimitiveType.DOUBLE,
- ResponseReader.DOUBLE);
- JPRIMITIVETYPE_TO_RESPONSEREADER.put(JPrimitiveType.FLOAT,
- ResponseReader.FLOAT);
+ JPRIMITIVETYPE_TO_RESPONSEREADER.put(JPrimitiveType.BOOLEAN, ResponseReader.BOOLEAN);
+ JPRIMITIVETYPE_TO_RESPONSEREADER.put(JPrimitiveType.BYTE, ResponseReader.BYTE);
+ JPRIMITIVETYPE_TO_RESPONSEREADER.put(JPrimitiveType.CHAR, ResponseReader.CHAR);
+ JPRIMITIVETYPE_TO_RESPONSEREADER.put(JPrimitiveType.DOUBLE, ResponseReader.DOUBLE);
+ JPRIMITIVETYPE_TO_RESPONSEREADER.put(JPrimitiveType.FLOAT, ResponseReader.FLOAT);
JPRIMITIVETYPE_TO_RESPONSEREADER.put(JPrimitiveType.INT, ResponseReader.INT);
- JPRIMITIVETYPE_TO_RESPONSEREADER.put(JPrimitiveType.LONG,
- ResponseReader.LONG);
- JPRIMITIVETYPE_TO_RESPONSEREADER.put(JPrimitiveType.SHORT,
- ResponseReader.SHORT);
- JPRIMITIVETYPE_TO_RESPONSEREADER.put(JPrimitiveType.VOID,
- ResponseReader.VOID);
+ JPRIMITIVETYPE_TO_RESPONSEREADER.put(JPrimitiveType.LONG, ResponseReader.LONG);
+ JPRIMITIVETYPE_TO_RESPONSEREADER.put(JPrimitiveType.SHORT, ResponseReader.SHORT);
+ JPRIMITIVETYPE_TO_RESPONSEREADER.put(JPrimitiveType.VOID, ResponseReader.VOID);
}
public ProxyCreator(JClassType serviceIntf) {
@@ -245,21 +228,19 @@
/**
* Creates the client-side proxy class.
- *
+ *
* @throws UnableToCompleteException
*/
public String create(TreeLogger logger, GeneratorContextExt context)
throws UnableToCompleteException {
TypeOracle typeOracle = context.getTypeOracle();
- JClassType serviceAsync = typeOracle.findType(serviceIntf.getQualifiedSourceName()
- + "Async");
+ JClassType serviceAsync = typeOracle.findType(serviceIntf.getQualifiedSourceName() + "Async");
if (serviceAsync == null) {
logger.branch(TreeLogger.ERROR,
"Could not find an asynchronous version for the service interface "
+ serviceIntf.getQualifiedSourceName(), null);
- RemoteServiceAsyncValidator.logValidAsyncInterfaceDeclaration(logger,
- serviceIntf);
+ RemoteServiceAsyncValidator.logValidAsyncInterfaceDeclaration(logger, serviceIntf);
throw new UnableToCompleteException();
}
@@ -271,33 +252,30 @@
// Make sure that the async and synchronous versions of the RemoteService
// agree with one another
//
- RemoteServiceAsyncValidator rsav = new RemoteServiceAsyncValidator(logger,
- typeOracle);
- Map<JMethod, JMethod> syncMethToAsyncMethMap = rsav.validate(logger,
- serviceIntf, serviceAsync);
+ RemoteServiceAsyncValidator rsav = new RemoteServiceAsyncValidator(logger, typeOracle);
+ Map<JMethod, JMethod> syncMethToAsyncMethMap = rsav.validate(logger, serviceIntf, serviceAsync);
final PropertyOracle propertyOracle = context.getPropertyOracle();
// Load the blacklist/whitelist
- TypeFilter blacklistTypeFilter = new BlacklistTypeFilter(logger,
- propertyOracle);
+ TypeFilter blacklistTypeFilter = new BlacklistTypeFilter(logger, propertyOracle);
// Determine the set of serializable types
Event event = SpeedTracerLogger.start(CompilerEventType.GENERATOR_RPC_STOB);
- SerializableTypeOracleBuilder typesSentFromBrowserBuilder = new SerializableTypeOracleBuilder(
- logger, propertyOracle, context);
+ SerializableTypeOracleBuilder typesSentFromBrowserBuilder =
+ new SerializableTypeOracleBuilder(logger, propertyOracle, context);
typesSentFromBrowserBuilder.setTypeFilter(blacklistTypeFilter);
- SerializableTypeOracleBuilder typesSentToBrowserBuilder = new SerializableTypeOracleBuilder(
- logger, propertyOracle, context);
+ SerializableTypeOracleBuilder typesSentToBrowserBuilder =
+ new SerializableTypeOracleBuilder(logger, propertyOracle, context);
typesSentToBrowserBuilder.setTypeFilter(blacklistTypeFilter);
- addRoots(logger, typeOracle, typesSentFromBrowserBuilder,
- typesSentToBrowserBuilder);
+ addRoots(logger, typeOracle, typesSentFromBrowserBuilder, typesSentToBrowserBuilder);
try {
- ConfigurationProperty prop = context.getPropertyOracle().getConfigurationProperty(
- TypeSerializerCreator.GWT_ELIDE_TYPE_NAMES_FROM_RPC);
+ ConfigurationProperty prop =
+ context.getPropertyOracle().getConfigurationProperty(
+ TypeSerializerCreator.GWT_ELIDE_TYPE_NAMES_FROM_RPC);
elideTypeNames = Boolean.parseBoolean(prop.getValues().get(0));
} catch (BadPropertyValueException e) {
logger.log(TreeLogger.ERROR, "Configuration property "
@@ -335,36 +313,32 @@
}
event.end();
- generateTypeHandlers(logger, context, typesSentFromBrowser,
- typesSentToBrowser);
+ generateTypeHandlers(logger, context, typesSentFromBrowser, typesSentToBrowser);
- String serializationPolicyStrongName = writeSerializationPolicyFile(logger,
- context, typesSentFromBrowser, typesSentToBrowser);
+ String serializationPolicyStrongName =
+ writeSerializationPolicyFile(logger, context, typesSentFromBrowser, typesSentToBrowser);
- String remoteServiceInterfaceName = elideTypeNames
- ? TypeNameObfuscator.SERVICE_INTERFACE_ID
- : SerializationUtils.getRpcTypeName(serviceIntf);
- generateProxyFields(srcWriter, typesSentFromBrowser,
- serializationPolicyStrongName, remoteServiceInterfaceName);
+ String remoteServiceInterfaceName =
+ elideTypeNames ? TypeNameObfuscator.SERVICE_INTERFACE_ID : SerializationUtils
+ .getRpcTypeName(serviceIntf);
+ generateProxyFields(srcWriter, typesSentFromBrowser, serializationPolicyStrongName,
+ remoteServiceInterfaceName);
generateProxyContructor(srcWriter);
- generateProxyMethods(srcWriter, typesSentFromBrowser, typeOracle,
- syncMethToAsyncMethMap);
+ generateProxyMethods(srcWriter, typesSentFromBrowser, typeOracle, syncMethToAsyncMethMap);
generateStreamWriterOverride(srcWriter);
- generateCheckRpcTokenTypeOverride(srcWriter, typeOracle,
- typesSentFromBrowser);
+ generateCheckRpcTokenTypeOverride(srcWriter, typeOracle, typesSentFromBrowser);
srcWriter.commit(logger);
if (context.isProdMode() || logger.isLoggable(TreeLogger.DEBUG)) {
// Create an artifact explaining STOB's decisions. It will be emitted by
// RpcLogLinker
- context.commitArtifact(logger,
- new RpcLogArtifact(serviceIntf.getQualifiedSourceName(),
- serializationPolicyStrongName, rpcLog));
+ context.commitArtifact(logger, new RpcLogArtifact(serviceIntf.getQualifiedSourceName(),
+ serializationPolicyStrongName, rpcLog));
}
return getProxyQualifiedName();
@@ -372,17 +346,15 @@
protected void addRoots(TreeLogger logger, TypeOracle typeOracle,
SerializableTypeOracleBuilder typesSentFromBrowserBuilder,
- SerializableTypeOracleBuilder typesSentToBrowserBuilder)
- throws UnableToCompleteException {
+ SerializableTypeOracleBuilder typesSentToBrowserBuilder) throws UnableToCompleteException {
try {
addRequiredRoots(logger, typeOracle, typesSentFromBrowserBuilder);
addRequiredRoots(logger, typeOracle, typesSentToBrowserBuilder);
- addRemoteServiceRootTypes(logger, typeOracle,
- typesSentFromBrowserBuilder, typesSentToBrowserBuilder, serviceIntf);
+ addRemoteServiceRootTypes(logger, typeOracle, typesSentFromBrowserBuilder,
+ typesSentToBrowserBuilder, serviceIntf);
} catch (NotFoundException e) {
- logger.log(TreeLogger.ERROR,
- "Unable to find type referenced from remote service", e);
+ logger.log(TreeLogger.ERROR, "Unable to find type referenced from remote service", e);
throw new UnableToCompleteException();
}
}
@@ -397,8 +369,8 @@
return typeName == null ? null : ('"' + typeName + '"');
}
- protected void generateCheckRpcTokenTypeOverride(SourceWriter srcWriter,
- TypeOracle typeOracle, SerializableTypeOracle typesSentFromBrowser) {
+ protected void generateCheckRpcTokenTypeOverride(SourceWriter srcWriter, TypeOracle typeOracle,
+ SerializableTypeOracle typesSentFromBrowser) {
JClassType rpcTokenType = typeOracle.findType(RpcToken.class.getName());
JClassType[] rpcTokenSubtypes = rpcTokenType.getSubtypes();
String rpcTokenImplementation = "";
@@ -417,18 +389,17 @@
srcWriter.println("@Override");
srcWriter.println("protected void checkRpcTokenType(RpcToken token) {");
srcWriter.indent();
- srcWriter.println("if (!(token instanceof " + rpcTokenImplementation
- + ")) {");
+ srcWriter.println("if (!(token instanceof " + rpcTokenImplementation + ")) {");
srcWriter.indent();
- srcWriter.println("throw new RpcTokenException(\"Invalid RpcToken type: "
- + "expected '" + rpcTokenImplementation + "' but got '\" + "
- + "token.getClass() + \"'\");");
+ srcWriter.println("throw new RpcTokenException(\"Invalid RpcToken type: " + "expected '"
+ + rpcTokenImplementation + "' but got '\" + " + "token.getClass() + \"'\");");
srcWriter.outdent();
srcWriter.println("}");
srcWriter.outdent();
srcWriter.println("}");
}
}
+
/**
* Generate the proxy constructor and delegate to the superclass constructor
* using the default address for the
@@ -449,31 +420,30 @@
/**
* Generate any fields required by the proxy.
- *
+ *
* @param serializableTypeOracle the type oracle
*/
protected void generateProxyFields(SourceWriter srcWriter,
- SerializableTypeOracle serializableTypeOracle,
- String serializationPolicyStrongName, String remoteServiceInterfaceName) {
+ SerializableTypeOracle serializableTypeOracle, String serializationPolicyStrongName,
+ String remoteServiceInterfaceName) {
// Initialize a field with binary name of the remote service interface
- srcWriter.println("private static final String REMOTE_SERVICE_INTERFACE_NAME = "
- + "\"" + remoteServiceInterfaceName + "\";");
+ srcWriter.println("private static final String REMOTE_SERVICE_INTERFACE_NAME = " + "\""
+ + remoteServiceInterfaceName + "\";");
srcWriter.println("private static final String SERIALIZATION_POLICY =\""
+ serializationPolicyStrongName + "\";");
String typeSerializerName = SerializationUtils.getTypeSerializerQualifiedName(serviceIntf);
- srcWriter.println("private static final " + typeSerializerName
- + " SERIALIZER = new " + typeSerializerName + "();");
+ srcWriter.println("private static final " + typeSerializerName + " SERIALIZER = new "
+ + typeSerializerName + "();");
srcWriter.println();
}
/**
* Generates the client's asynchronous proxy method.
- *
+ *
* @param serializableTypeOracle the type oracle
*/
- protected void generateProxyMethod(SourceWriter w,
- SerializableTypeOracle serializableTypeOracle, TypeOracle typeOracle,
- JMethod syncMethod, JMethod asyncMethod) {
+ protected void generateProxyMethod(SourceWriter w, SerializableTypeOracle serializableTypeOracle,
+ TypeOracle typeOracle, JMethod syncMethod, JMethod asyncMethod) {
w.println();
@@ -516,9 +486,8 @@
String helperName = nameFactory.createName("helper");
String helperClassName = RemoteServiceProxy.ServiceHelper.class.getCanonicalName();
- w.println("%s %s = new %s(\"%s\", \"%s\");",
- helperClassName, helperName, helperClassName, getProxySimpleName(),
- syncMethod.getName());
+ w.println("%s %s = new %s(\"%s\", \"%s\");", helperClassName, helperName, helperClassName,
+ getProxySimpleName(), syncMethod.getName());
w.println("try {");
w.indent();
@@ -528,8 +497,8 @@
String streamWriterName = nameFactory.createName("streamWriter");
w.println("%s %s = %s.start(REMOTE_SERVICE_INTERFACE_NAME, %s);",
- SerializationStreamWriter.class.getSimpleName(), streamWriterName,
- helperName, syncParams.length);
+ SerializationStreamWriter.class.getSimpleName(), streamWriterName, helperName,
+ syncParams.length);
for (JParameter param : syncParams) {
JType paramType = param.getType().getErasedType();
@@ -558,16 +527,14 @@
String callbackName = callbackParam.getName();
if (asyncReturnType == JPrimitiveType.VOID) {
- w.println("%s.finish(%s, ResponseReader.%s);",
- helperName, callbackName, getResponseReaderFor(returnType).name());
- } else if (asyncReturnType.getQualifiedSourceName().equals(
- RequestBuilder.class.getName())) {
- w.println("return %s.finishForRequestBuilder(%s, ResponseReader.%s);",
- helperName, callbackName, getResponseReaderFor(returnType).name());
- } else if (asyncReturnType.getQualifiedSourceName().equals(
- Request.class.getName())) {
- w.println("return %s.finish(%s, ResponseReader.%s);",
- helperName, callbackName, getResponseReaderFor(returnType).name());
+ w.println("%s.finish(%s, ResponseReader.%s);", helperName, callbackName,
+ getResponseReaderFor(returnType).name());
+ } else if (asyncReturnType.getQualifiedSourceName().equals(RequestBuilder.class.getName())) {
+ w.println("return %s.finishForRequestBuilder(%s, ResponseReader.%s);", helperName,
+ callbackName, getResponseReaderFor(returnType).name());
+ } else if (asyncReturnType.getQualifiedSourceName().equals(Request.class.getName())) {
+ w.println("return %s.finish(%s, ResponseReader.%s);", helperName, callbackName,
+ getResponseReaderFor(returnType).name());
} else {
// This method should have been caught by RemoteServiceAsyncValidator
throw new RuntimeException("Unhandled return type "
@@ -579,8 +546,7 @@
String exceptionName = nameFactory.createName("ex");
w.println(exceptionName + ") {");
w.indent();
- if (!asyncReturnType.getQualifiedSourceName().equals(
- RequestBuilder.class.getName())) {
+ if (!asyncReturnType.getQualifiedSourceName().equals(RequestBuilder.class.getName())) {
/*
* If the method returns void or Request, signal the serialization error
* immediately. If the method returns RequestBuilder, the error will be
@@ -588,12 +554,10 @@
*/
w.println(callbackName + ".onFailure(" + exceptionName + ");");
}
- if (asyncReturnType.getQualifiedSourceName().equals(
- RequestBuilder.class.getName())) {
- w.println("return new " + FailingRequestBuilder.class.getName() + "("
- + exceptionName + ", " + callbackName + ");");
- } else if (asyncReturnType.getQualifiedSourceName().equals(
- Request.class.getName())) {
+ if (asyncReturnType.getQualifiedSourceName().equals(RequestBuilder.class.getName())) {
+ w.println("return new " + FailingRequestBuilder.class.getName() + "(" + exceptionName + ", "
+ + callbackName + ");");
+ } else if (asyncReturnType.getQualifiedSourceName().equals(Request.class.getName())) {
w.println("return new " + FailedRequest.class.getName() + "();");
} else {
assert asyncReturnType == JPrimitiveType.VOID;
@@ -629,8 +593,7 @@
}
}
- generateProxyMethod(w, serializableTypeOracle, typeOracle, syncMethod,
- asyncMethod);
+ generateProxyMethod(w, serializableTypeOracle, typeOracle, syncMethod, asyncMethod);
}
}
@@ -639,8 +602,8 @@
* @param asyncMethod
* @param statsContextName
*/
- protected void generateRpcStatsContext(SourceWriter w, JMethod syncMethod,
- JMethod asyncMethod, String statsContextName) {
+ protected void generateRpcStatsContext(SourceWriter w, JMethod syncMethod, JMethod asyncMethod,
+ String statsContextName) {
w.println("RpcStatsContext " + statsContextName + " = new RpcStatsContext();");
}
@@ -669,15 +632,14 @@
srcWriter.println("}");
}
- protected void generateTypeHandlers(TreeLogger logger,
- GeneratorContextExt context, SerializableTypeOracle typesSentFromBrowser,
- SerializableTypeOracle typesSentToBrowser)
+ protected void generateTypeHandlers(TreeLogger logger, GeneratorContextExt context,
+ SerializableTypeOracle typesSentFromBrowser, SerializableTypeOracle typesSentToBrowser)
throws UnableToCompleteException {
Event event = SpeedTracerLogger.start(CompilerEventType.GENERATOR_RPC_TYPE_SERIALIZER);
- TypeSerializerCreator tsc = new TypeSerializerCreator(logger,
- typesSentFromBrowser, typesSentToBrowser, context,
- SerializationUtils.getTypeSerializerQualifiedName(serviceIntf),
- SerializationUtils.getTypeSerializerSimpleName(serviceIntf));
+ TypeSerializerCreator tsc =
+ new TypeSerializerCreator(logger, typesSentFromBrowser, typesSentToBrowser, context,
+ SerializationUtils.getTypeSerializerQualifiedName(serviceIntf), SerializationUtils
+ .getTypeSerializerSimpleName(serviceIntf));
tsc.realize(logger);
event.end();
@@ -686,8 +648,7 @@
}
protected String getProxySimpleName() {
- String[] name = Shared.synthesizeTopLevelClassName(serviceIntf,
- PROXY_SUFFIX);
+ String[] name = Shared.synthesizeTopLevelClassName(serviceIntf, PROXY_SUFFIX);
return name[1];
}
@@ -696,7 +657,8 @@
}
protected String getRemoteServiceRelativePath() {
- RemoteServiceRelativePath moduleRelativeURL = serviceIntf.getAnnotation(RemoteServiceRelativePath.class);
+ RemoteServiceRelativePath moduleRelativeURL =
+ serviceIntf.getAnnotation(RemoteServiceRelativePath.class);
if (moduleRelativeURL != null) {
return "\"" + moduleRelativeURL.value() + "\"";
}
@@ -708,40 +670,35 @@
return ClientSerializationStreamWriter.class;
}
- protected String writeSerializationPolicyFile(TreeLogger logger,
- GeneratorContextExt ctx, SerializableTypeOracle serializationSto,
- SerializableTypeOracle deserializationSto)
+ protected String writeSerializationPolicyFile(TreeLogger logger, GeneratorContextExt ctx,
+ SerializableTypeOracle serializationSto, SerializableTypeOracle deserializationSto)
throws UnableToCompleteException {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- OutputStreamWriter osw = new OutputStreamWriter(baos,
- SerializationPolicyLoader.SERIALIZATION_POLICY_FILE_ENCODING);
+ OutputStreamWriter osw =
+ new OutputStreamWriter(baos, SerializationPolicyLoader.SERIALIZATION_POLICY_FILE_ENCODING);
TypeOracle oracle = ctx.getTypeOracle();
PrintWriter pw = new PrintWriter(osw);
- JType[] serializableTypes = unionOfTypeArrays(
- serializationSto.getSerializableTypes(),
- deserializationSto.getSerializableTypes(), new JType[] {serviceIntf});
+ JType[] serializableTypes =
+ unionOfTypeArrays(serializationSto.getSerializableTypes(), deserializationSto
+ .getSerializableTypes(), new JType[] {serviceIntf});
for (int i = 0; i < serializableTypes.length; ++i) {
JType type = serializableTypes[i];
String binaryTypeName = SerializationUtils.getRpcTypeName(type);
pw.print(binaryTypeName);
- pw.print(", "
- + Boolean.toString(deserializationSto.isSerializable(type)));
- pw.print(", "
- + Boolean.toString(deserializationSto.maybeInstantiated(type)));
+ pw.print(", " + Boolean.toString(deserializationSto.isSerializable(type)));
+ pw.print(", " + Boolean.toString(deserializationSto.maybeInstantiated(type)));
pw.print(", " + Boolean.toString(serializationSto.isSerializable(type)));
- pw.print(", "
- + Boolean.toString(serializationSto.maybeInstantiated(type)));
+ pw.print(", " + Boolean.toString(serializationSto.maybeInstantiated(type)));
pw.print(", " + typeStrings.get(type));
/*
* Include the serialization signature to bump the RPC file name if
* obfuscated identifiers are used.
*/
- pw.print(", "
- + SerializationUtils.getSerializationSignature(oracle, type));
+ pw.print(", " + SerializationUtils.getSerializationSignature(oracle, type));
pw.print('\n');
/*
@@ -778,9 +735,9 @@
byte[] serializationPolicyFileContents = baos.toByteArray();
String serializationPolicyName = Util.computeStrongName(serializationPolicyFileContents);
- String serializationPolicyFileName = SerializationPolicyLoader.getSerializationPolicyFileName(serializationPolicyName);
- OutputStream os = ctx.tryCreateResource(logger,
- serializationPolicyFileName);
+ String serializationPolicyFileName =
+ SerializationPolicyLoader.getSerializationPolicyFileName(serializationPolicyName);
+ OutputStream os = ctx.tryCreateResource(logger, serializationPolicyFileName);
if (os != null) {
os.write(serializationPolicyFileContents);
GeneratedResource resource = ctx.commitResource(logger, os);
@@ -792,18 +749,16 @@
emitPolicyFileArtifact(logger, ctx, resource.getPartialPath());
} else {
if (logger.isLoggable(TreeLogger.TRACE)) {
- logger.log(TreeLogger.TRACE,
- "SerializationPolicy file for RemoteService '"
- + serviceIntf.getQualifiedSourceName()
- + "' already exists; no need to rewrite it.", null);
+ logger.log(TreeLogger.TRACE, "SerializationPolicy file for RemoteService '"
+ + serviceIntf.getQualifiedSourceName() + "' already exists; no need to rewrite it.",
+ null);
}
}
return serializationPolicyName;
} catch (UnsupportedEncodingException e) {
- logger.log(TreeLogger.ERROR,
- SerializationPolicyLoader.SERIALIZATION_POLICY_FILE_ENCODING
- + " is not supported", e);
+ logger.log(TreeLogger.ERROR, SerializationPolicyLoader.SERIALIZATION_POLICY_FILE_ENCODING
+ + " is not supported", e);
throw new UnableToCompleteException();
} catch (IOException e) {
logger.log(TreeLogger.ERROR, null, e);
@@ -811,32 +766,30 @@
}
}
- private void emitPolicyFileArtifact(TreeLogger logger,
- GeneratorContextExt context, String partialPath)
- throws UnableToCompleteException {
+ private void emitPolicyFileArtifact(TreeLogger logger, GeneratorContextExt context,
+ String partialPath) throws UnableToCompleteException {
try {
String qualifiedSourceName = serviceIntf.getQualifiedSourceName();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Writer writer;
- writer = new OutputStreamWriter(baos,
- SerializationPolicyLoader.SERIALIZATION_POLICY_FILE_ENCODING);
+ writer =
+ new OutputStreamWriter(baos, SerializationPolicyLoader.SERIALIZATION_POLICY_FILE_ENCODING);
writer.write("serviceClass: " + qualifiedSourceName + "\n");
writer.write("path: " + partialPath + "\n");
writer.close();
byte[] manifestBytes = baos.toByteArray();
String md5 = Util.computeStrongName(manifestBytes);
- OutputStream os = context.tryCreateResource(logger, MANIFEST_ARTIFACT_DIR
- + "/" + md5 + ".txt");
+ OutputStream os =
+ context.tryCreateResource(logger, MANIFEST_ARTIFACT_DIR + "/" + md5 + ".txt");
os.write(manifestBytes);
GeneratedResource resource = context.commitResource(logger, os);
// TODO: change to Deploy when possible
resource.setVisibility(Visibility.LegacyDeploy);
} catch (UnsupportedEncodingException e) {
- logger.log(TreeLogger.ERROR,
- SerializationPolicyLoader.SERIALIZATION_POLICY_FILE_ENCODING
- + " is not supported", e);
+ logger.log(TreeLogger.ERROR, SerializationPolicyLoader.SERIALIZATION_POLICY_FILE_ENCODING
+ + " is not supported", e);
throw new UnableToCompleteException();
} catch (IOException e) {
logger.log(TreeLogger.ERROR, null, e);
@@ -845,8 +798,7 @@
}
private String getProxyQualifiedName() {
- String[] name = Shared.synthesizeTopLevelClassName(serviceIntf,
- PROXY_SUFFIX);
+ String[] name = Shared.synthesizeTopLevelClassName(serviceIntf, PROXY_SUFFIX);
return name[0].length() == 0 ? name[1] : name[0] + "." + name[1];
}
@@ -855,8 +807,7 @@
return JPRIMITIVETYPE_TO_RESPONSEREADER.get(returnType.isPrimitive());
}
- if (returnType.getQualifiedSourceName().equals(
- String.class.getCanonicalName())) {
+ if (returnType.getQualifiedSourceName().equals(String.class.getCanonicalName())) {
return ResponseReader.STRING;
}
@@ -867,25 +818,22 @@
JClassType serviceAsync) {
JPackage serviceIntfPkg = serviceAsync.getPackage();
String packageName = serviceIntfPkg == null ? "" : serviceIntfPkg.getName();
- PrintWriter printWriter = ctx.tryCreate(logger, packageName,
- getProxySimpleName());
+ PrintWriter printWriter = ctx.tryCreate(logger, packageName, getProxySimpleName());
if (printWriter == null) {
return null;
}
- ClassSourceFileComposerFactory composerFactory = new ClassSourceFileComposerFactory(
- packageName, getProxySimpleName());
+ ClassSourceFileComposerFactory composerFactory =
+ new ClassSourceFileComposerFactory(packageName, getProxySimpleName());
- String[] imports = new String[] {
- getProxySupertype().getCanonicalName(),
- getStreamWriterClass().getCanonicalName(),
- SerializationStreamWriter.class.getCanonicalName(),
- GWT.class.getCanonicalName(), ResponseReader.class.getCanonicalName(),
- SerializationException.class.getCanonicalName(),
- RpcToken.class.getCanonicalName(),
- RpcTokenException.class.getCanonicalName(),
- Impl.class.getCanonicalName(),
- RpcStatsContext.class.getCanonicalName()};
+ String[] imports =
+ new String[] {
+ getProxySupertype().getCanonicalName(), getStreamWriterClass().getCanonicalName(),
+ SerializationStreamWriter.class.getCanonicalName(), GWT.class.getCanonicalName(),
+ ResponseReader.class.getCanonicalName(),
+ SerializationException.class.getCanonicalName(), RpcToken.class.getCanonicalName(),
+ RpcTokenException.class.getCanonicalName(), Impl.class.getCanonicalName(),
+ RpcStatsContext.class.getCanonicalName()};
for (String imp : imports) {
composerFactory.addImport(imp);
}
diff --git a/user/src/com/google/gwt/user/rebind/rpc/RemoteServiceAsyncValidator.java b/user/src/com/google/gwt/user/rebind/rpc/RemoteServiceAsyncValidator.java
index 97c6f70..9b496b7 100644
--- a/user/src/com/google/gwt/user/rebind/rpc/RemoteServiceAsyncValidator.java
+++ b/user/src/com/google/gwt/user/rebind/rpc/RemoteServiceAsyncValidator.java
@@ -38,19 +38,17 @@
* {@link com.google.gwt.user.client.rpc.RemoteService RemoteService} interface.
*/
class RemoteServiceAsyncValidator {
- static void logValidAsyncInterfaceDeclaration(TreeLogger logger,
- JClassType remoteService) {
- TreeLogger branch = logger.branch(TreeLogger.INFO,
- "A valid definition for the asynchronous version of interface '"
- + remoteService.getQualifiedSourceName() + "' would be:\n", null);
- branch.log(TreeLogger.ERROR,
- synthesizeAsynchronousInterfaceDefinition(remoteService), null);
+ static void logValidAsyncInterfaceDeclaration(TreeLogger logger, JClassType remoteService) {
+ TreeLogger branch =
+ logger.branch(TreeLogger.INFO,
+ "A valid definition for the asynchronous version of interface '"
+ + remoteService.getQualifiedSourceName() + "' would be:\n", null);
+ branch.log(TreeLogger.ERROR, synthesizeAsynchronousInterfaceDefinition(remoteService), null);
}
private static String computeAsyncMethodSignature(JMethod syncMethod,
JClassType asyncCallbackClass) {
- return computeInternalSignature(syncMethod) + "/"
- + asyncCallbackClass.getQualifiedSourceName();
+ return computeInternalSignature(syncMethod) + "/" + asyncCallbackClass.getQualifiedSourceName();
}
private static String computeInternalSignature(JMethod method) {
@@ -70,8 +68,7 @@
* Builds a map of asynchronous method internal signatures to the
* corresponding asynchronous {@link JMethod}.
*/
- private static Map<String, JMethod> initializeAsyncMethodMap(
- JMethod[] asyncMethods) {
+ private static Map<String, JMethod> initializeAsyncMethodMap(JMethod[] asyncMethods) {
Map<String, JMethod> sigs = new TreeMap<String, JMethod>();
for (JMethod asyncMethod : asyncMethods) {
sigs.put(computeInternalSignature(asyncMethod), asyncMethod);
@@ -79,8 +76,7 @@
return sigs;
}
- private static String synthesizeAsynchronousInterfaceDefinition(
- JClassType serviceIntf) {
+ private static String synthesizeAsynchronousInterfaceDefinition(JClassType serviceIntf) {
StringBuffer sb = new StringBuffer();
JPackage pkg = serviceIntf.getPackage();
if (pkg != null) {
@@ -134,8 +130,8 @@
return sb.toString();
}
- private static void validationFailed(TreeLogger branch,
- JClassType remoteService) throws UnableToCompleteException {
+ private static void validationFailed(TreeLogger branch, JClassType remoteService)
+ throws UnableToCompleteException {
logValidAsyncInterfaceDeclaration(branch, remoteService);
throw new UnableToCompleteException();
}
@@ -178,17 +174,15 @@
* @return map of synchronous method to asynchronous method
*
* @throws UnableToCompleteException if the asynchronous
- * {@link com.google.gwt.user.client.rpc.RemoteService RemoteService}
- * was not found, or if it does not have an asynchronous method
- * version of every synchronous one
+ * {@link com.google.gwt.user.client.rpc.RemoteService
+ * RemoteService} was not found, or if it does not have an
+ * asynchronous method version of every synchronous one
*/
- public Map<JMethod, JMethod> validate(TreeLogger logger,
- JClassType remoteService, JClassType remoteServiceAsync)
- throws UnableToCompleteException {
- TreeLogger branch = logger.branch(TreeLogger.DEBUG,
- "Checking the synchronous interface '"
- + remoteService.getQualifiedSourceName()
- + "' against its asynchronous version '"
+ public Map<JMethod, JMethod> validate(TreeLogger logger, JClassType remoteService,
+ JClassType remoteServiceAsync) throws UnableToCompleteException {
+ TreeLogger branch =
+ logger.branch(TreeLogger.DEBUG, "Checking the synchronous interface '"
+ + remoteService.getQualifiedSourceName() + "' against its asynchronous version '"
+ remoteServiceAsync.getQualifiedSourceName() + "'", null);
// Sync and async versions must have the same number of methods
@@ -207,13 +201,11 @@
Map<String, JMethod> asyncMethodMap = initializeAsyncMethodMap(asyncMethods);
Map<JMethod, JMethod> syncMethodToAsyncMethodMap = new HashMap<JMethod, JMethod>();
for (JMethod syncMethod : syncMethods) {
- String asyncSig = computeAsyncMethodSignature(syncMethod,
- asyncCallbackClass);
+ String asyncSig = computeAsyncMethodSignature(syncMethod, asyncCallbackClass);
JMethod asyncMethod = asyncMethodMap.get(asyncSig);
if (asyncMethod == null) {
- branch.branch(TreeLogger.ERROR,
- "Missing asynchronous version of the synchronous method '"
- + syncMethod.getReadableDeclaration() + "'", null);
+ branch.branch(TreeLogger.ERROR, "Missing asynchronous version of the synchronous method '"
+ + syncMethod.getReadableDeclaration() + "'", null);
failed = true;
} else {
// TODO if async param is parameterized make sure that the sync return
@@ -221,12 +213,10 @@
JType returnType = asyncMethod.getReturnType();
if (returnType != JPrimitiveType.VOID && returnType != requestType
&& returnType != requestBuilderType) {
- branch.branch(TreeLogger.ERROR,
- "The asynchronous version of the synchronous method '"
- + syncMethod.getReadableDeclaration()
- + "' must have a return type of 'void' or '"
- + Request.class.getCanonicalName() + "' or '"
- + RequestBuilder.class.getCanonicalName() + "'", null);
+ branch.branch(TreeLogger.ERROR, "The asynchronous version of the synchronous method '"
+ + syncMethod.getReadableDeclaration() + "' must have a return type of 'void' or '"
+ + Request.class.getCanonicalName() + "' or '"
+ + RequestBuilder.class.getCanonicalName() + "'", null);
failed = true;
} else {
syncMethodToAsyncMethodMap.put(syncMethod, asyncMethod);
diff --git a/user/src/com/google/gwt/user/rebind/rpc/SerializableTypeOracle.java b/user/src/com/google/gwt/user/rebind/rpc/SerializableTypeOracle.java
index 942e68a..eda25d1 100644
--- a/user/src/com/google/gwt/user/rebind/rpc/SerializableTypeOracle.java
+++ b/user/src/com/google/gwt/user/rebind/rpc/SerializableTypeOracle.java
@@ -42,7 +42,7 @@
boolean isSerializable(JType type);
/**
- * Returns <code>true</code> if the type might be instantiated as part of
+ * Returns <code>true</code> if the type might be instantiated as part of
* deserialization or serialization.
*
* @param type the type to test
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 14de07e..5673994 100644
--- a/user/src/com/google/gwt/user/rebind/rpc/SerializableTypeOracleBuilder.java
+++ b/user/src/com/google/gwt/user/rebind/rpc/SerializableTypeOracleBuilder.java
@@ -184,8 +184,7 @@
autoSerializable = SerializableTypeOracleBuilder.isAutoSerializable(typeClass);
manualSerializer = findCustomFieldSerializer(typeOracle, typeClass);
directlyImplementsMarker = directlyImplementsMarkerInterface(typeClass);
- maybeEnhanced = hasJdoAnnotation(typeClass)
- || hasJpaAnnotation(typeClass);
+ maybeEnhanced = hasJdoAnnotation(typeClass) || hasJpaAnnotation(typeClass);
} else {
autoSerializable = false;
manualSerializer = null;
@@ -218,8 +217,7 @@
}
public boolean hasInstantiableSubtypes() {
- return isInstantiable() || instantiableSubtypes
- || isPendingInstantiable();
+ return isInstantiable() || instantiableSubtypes || isPendingInstantiable();
}
public boolean isAutoSerializable() {
@@ -348,11 +346,10 @@
static {
try {
- JDO_PERSISTENCE_CAPABLE_ANNOTATION = Class.forName(
- "javax.jdo.annotations.PersistenceCapable").asSubclass(
- Annotation.class);
- JDO_PERSISTENCE_CAPABLE_DETACHABLE_METHOD = JDO_PERSISTENCE_CAPABLE_ANNOTATION.getDeclaredMethod(
- "detachable", (Class[]) null);
+ JDO_PERSISTENCE_CAPABLE_ANNOTATION =
+ Class.forName("javax.jdo.annotations.PersistenceCapable").asSubclass(Annotation.class);
+ JDO_PERSISTENCE_CAPABLE_DETACHABLE_METHOD =
+ JDO_PERSISTENCE_CAPABLE_ANNOTATION.getDeclaredMethod("detachable", (Class[]) null);
} catch (ClassNotFoundException e) {
// Ignore, JDO_PERSISTENCE_CAPABLE_ANNOTATION will be null
} catch (NoSuchMethodException e) {
@@ -360,8 +357,8 @@
}
try {
- JPA_ENTITY_ANNOTATION = Class.forName("javax.persistence.Entity").asSubclass(
- Annotation.class);
+ JPA_ENTITY_ANNOTATION =
+ Class.forName("javax.persistence.Entity").asSubclass(Annotation.class);
} catch (ClassNotFoundException e) {
// Ignore, JPA_ENTITY_CAPABLE_ANNOTATION will be null
}
@@ -379,8 +376,8 @@
// Warn and return false.
problems.add(type, type.getParameterizedQualifiedSourceName()
+ " is not default instantiable (it must have a zero-argument "
- + "constructor or no constructors at all) and has no custom "
- + "serializer.", Priority.DEFAULT);
+ + "constructor or no constructors at all) and has no custom " + "serializer.",
+ Priority.DEFAULT);
return false;
}
} else {
@@ -401,21 +398,19 @@
* @return the custom field serializer for a type or <code>null</code> if
* there is not one
*/
- public static JClassType findCustomFieldSerializer(TypeOracle typeOracle,
- JType type) {
+ public static JClassType findCustomFieldSerializer(TypeOracle typeOracle, JType type) {
JClassType classOrInterface = type.isClassOrInterface();
if (classOrInterface == null) {
return null;
}
- String customFieldSerializerName = type.getQualifiedSourceName()
- + "_CustomFieldSerializer";
+ String customFieldSerializerName = type.getQualifiedSourceName() + "_CustomFieldSerializer";
JClassType customSerializer = typeOracle.findType(customFieldSerializerName);
if (customSerializer == null) {
// If the type is in the java.lang or java.util packages then it will be
// mapped into com.google.gwt.user.client.rpc.core package
- customSerializer = typeOracle.findType("com.google.gwt.user.client.rpc.core."
- + customFieldSerializerName);
+ customSerializer =
+ typeOracle.findType("com.google.gwt.user.client.rpc.core." + customFieldSerializerName);
}
return customSerializer;
@@ -445,8 +440,7 @@
return false;
}
try {
- Object value = JDO_PERSISTENCE_CAPABLE_DETACHABLE_METHOD.invoke(
- annotation, (Object[]) null);
+ Object value = JDO_PERSISTENCE_CAPABLE_DETACHABLE_METHOD.invoke(annotation, (Object[]) null);
if (value instanceof String) {
return "true".equalsIgnoreCase((String) value);
} else {
@@ -477,8 +471,7 @@
try {
JClassType isSerializable = getIsSerializableMarkerInterface(type);
JClassType serializable = getSerializableMarkerInterface(type);
- return type.isAssignableTo(isSerializable)
- || type.isAssignableTo(serializable);
+ return type.isAssignableTo(isSerializable) || type.isAssignableTo(serializable);
} catch (NotFoundException e) {
return false;
}
@@ -531,27 +524,24 @@
* serialization. If it returns <code>false</code> then none of the fields of
* this class should be serialized.
*/
- static boolean shouldConsiderFieldsForSerialization(JClassType type,
- TypeFilter filter, ProblemReport problems) {
+ static boolean shouldConsiderFieldsForSerialization(JClassType type, TypeFilter filter,
+ ProblemReport problems) {
if (!isAllowedByFilter(filter, type, problems)) {
return false;
}
if (!isDeclaredSerializable(type)) {
- problems.add(type, type.getParameterizedQualifiedSourceName()
- + " is not assignable to '" + IsSerializable.class.getName()
- + "' or '" + Serializable.class.getName()
+ problems.add(type, type.getParameterizedQualifiedSourceName() + " is not assignable to '"
+ + IsSerializable.class.getName() + "' or '" + Serializable.class.getName()
+ "' nor does it have a custom field serializer", Priority.DEFAULT);
return false;
}
if (isManuallySerializable(type)) {
- JClassType manualSerializer = findCustomFieldSerializer(type.getOracle(),
- type);
+ JClassType manualSerializer = findCustomFieldSerializer(type.getOracle(), type);
assert (manualSerializer != null);
- List<String> fieldProblems = CustomFieldSerializerValidator.validate(
- manualSerializer, type);
+ List<String> fieldProblems = CustomFieldSerializerValidator.validate(manualSerializer, type);
if (!fieldProblems.isEmpty()) {
for (String problem : fieldProblems) {
problems.add(type, problem, Priority.FATAL);
@@ -565,17 +555,15 @@
// Class is not visible to a serializer class in the same package
problems.add(type, type.getParameterizedQualifiedSourceName()
+ " is not accessible from a class in its same package; it "
- + "will be excluded from the set of serializable types",
- Priority.DEFAULT);
+ + "will be excluded from the set of serializable types", Priority.DEFAULT);
return false;
}
if (type.isMemberType() && !type.isStatic()) {
// Non-static member types cannot be serialized
- problems.add(type, type.getParameterizedQualifiedSourceName()
- + " is nested but "
- + "not static; it will be excluded from the set of serializable "
- + "types", Priority.DEFAULT);
+ problems.add(type, type.getParameterizedQualifiedSourceName() + " is nested but "
+ + "not static; it will be excluded from the set of serializable " + "types",
+ Priority.DEFAULT);
return false;
}
}
@@ -608,9 +596,8 @@
} else {
logLevel = TreeLogger.WARN;
}
- logger.branch(suppressNonStaticFinalFieldWarnings ? TreeLogger.DEBUG
- : logLevel, "Field '" + field.toString()
- + "' will not be serialized because it is final", null);
+ logger.branch(suppressNonStaticFinalFieldWarnings ? TreeLogger.DEBUG : logLevel, "Field '"
+ + field.toString() + "' will not be serialized because it is final", null);
return false;
}
@@ -628,8 +615,7 @@
}
}
- private static JArrayType getArrayType(TypeOracle typeOracle, int rank,
- JType component) {
+ private static JArrayType getArrayType(TypeOracle typeOracle, int rank, JType component) {
assert (rank > 0);
JArrayType array = null;
@@ -673,8 +659,8 @@
return true;
}
- private static boolean isAllowedByFilter(TypeFilter filter,
- JClassType classType, ProblemReport problems) {
+ private static boolean isAllowedByFilter(TypeFilter filter, JClassType classType,
+ ProblemReport problems) {
if (!filter.isAllowed(classType)) {
problems.add(classType, classType.getParameterizedQualifiedSourceName()
+ " is excluded by type filter ", Priority.AUXILIARY);
@@ -689,26 +675,24 @@
}
private static boolean isDirectlySerializable(JClassType type) {
- return directlyImplementsMarkerInterface(type)
- || isManuallySerializable(type);
+ return directlyImplementsMarkerInterface(type) || isManuallySerializable(type);
}
private static boolean isManuallySerializable(JClassType type) {
return findCustomFieldSerializer(type.getOracle(), type) != null;
}
- private static void logSerializableTypes(TreeLogger logger,
- Set<JClassType> fieldSerializableTypes) {
+ private static void logSerializableTypes(TreeLogger logger, Set<JClassType> fieldSerializableTypes) {
if (!logger.isLoggable(TreeLogger.DEBUG)) {
return;
}
- TreeLogger localLogger = logger.branch(TreeLogger.DEBUG, "Identified "
- + fieldSerializableTypes.size() + " serializable type"
- + ((fieldSerializableTypes.size() == 1) ? "" : "s"), null);
+ TreeLogger localLogger =
+ logger.branch(TreeLogger.DEBUG, "Identified " + fieldSerializableTypes.size()
+ + " serializable type" + ((fieldSerializableTypes.size() == 1) ? "" : "s"), null);
for (JClassType fieldSerializableType : fieldSerializableTypes) {
- localLogger.branch(TreeLogger.DEBUG,
- fieldSerializableType.getParameterizedQualifiedSourceName(), null);
+ localLogger.branch(TreeLogger.DEBUG, fieldSerializableType
+ .getParameterizedQualifiedSourceName(), null);
}
}
@@ -720,7 +704,7 @@
private final JGenericType collectionClass;
private final GeneratorContextExt context;
-
+
private Set<String> enhancedClasses = null;
private PrintWriter logOutputWriter;
@@ -743,8 +727,8 @@
private final TypeOracle typeOracle;
- private final TypeParameterExposureComputer typeParameterExposureComputer = new TypeParameterExposureComputer(
- typeFilter);
+ private final TypeParameterExposureComputer typeParameterExposureComputer =
+ new TypeParameterExposureComputer(typeFilter);
/**
* The set of type parameters that appear in one of the root types.
@@ -757,7 +741,8 @@
/**
* Map of {@link JType} to {@link TypeInfoComputed}.
*/
- private final Map<JType, TypeInfoComputed> typeToTypeInfoComputed = new HashMap<JType, TypeInfoComputed>();
+ private final Map<JType, TypeInfoComputed> typeToTypeInfoComputed =
+ new HashMap<JType, TypeInfoComputed>();
/**
* Constructs a builder.
@@ -769,9 +754,8 @@
* @throws UnableToCompleteException if we fail to find one of our special
* types
*/
- public SerializableTypeOracleBuilder(TreeLogger logger,
- PropertyOracle propertyOracle, GeneratorContextExt context)
- throws UnableToCompleteException {
+ public SerializableTypeOracleBuilder(TreeLogger logger, PropertyOracle propertyOracle,
+ GeneratorContextExt context) throws UnableToCompleteException {
this.context = context;
this.typeOracle = context.getTypeOracle();
typeConstrainer = new TypeConstrainer(typeOracle);
@@ -784,8 +768,8 @@
throw new UnableToCompleteException();
}
- suppressNonStaticFinalFieldWarnings = Shared.shouldSuppressNonStaticFinalFieldWarnings(
- logger, propertyOracle);
+ suppressNonStaticFinalFieldWarnings =
+ Shared.shouldSuppressNonStaticFinalFieldWarnings(logger, propertyOracle);
enhancedClasses = Shared.getEnhancedTypes(propertyOracle);
}
@@ -817,8 +801,7 @@
* @throws UnableToCompleteException if there was not at least one
* instantiable type assignable to each of the specified root types
*/
- public SerializableTypeOracle build(TreeLogger logger)
- throws UnableToCompleteException {
+ public SerializableTypeOracle build(TreeLogger logger) throws UnableToCompleteException {
alreadyCheckedObject = false;
boolean allSucceeded = true;
@@ -826,8 +809,9 @@
for (Entry<JClassType, TreeLogger> entry : rootTypes.entrySet()) {
ProblemReport problems = new ProblemReport();
problems.setContextType(entry.getKey());
- boolean entrySucceeded = computeTypeInstantiability(entry.getValue(),
- entry.getKey(), TypePaths.createRootPath(entry.getKey()), problems).hasInstantiableSubtypes();
+ boolean entrySucceeded =
+ computeTypeInstantiability(entry.getValue(), entry.getKey(),
+ TypePaths.createRootPath(entry.getKey()), problems).hasInstantiableSubtypes();
if (!entrySucceeded) {
problems.report(logger, TreeLogger.ERROR, TreeLogger.INFO);
} else {
@@ -858,11 +842,9 @@
logReachableTypes(logger);
- Set<JClassType> possiblyInstantiatedTypes = new TreeSet<JClassType>(
- JTYPE_COMPARATOR);
+ Set<JClassType> possiblyInstantiatedTypes = new TreeSet<JClassType>(JTYPE_COMPARATOR);
- Set<JClassType> fieldSerializableTypes = new TreeSet<JClassType>(
- JTYPE_COMPARATOR);
+ Set<JClassType> fieldSerializableTypes = new TreeSet<JClassType>(JTYPE_COMPARATOR);
for (TypeInfoComputed tic : typeToTypeInfoComputed.values()) {
if (!(tic.getType() instanceof JClassType)) {
@@ -885,16 +867,14 @@
}
if (tic.maybeEnhanced()
- || (enhancedClasses != null
- && enhancedClasses.contains(type.getQualifiedSourceName()))) {
+ || (enhancedClasses != null && enhancedClasses.contains(type.getQualifiedSourceName()))) {
type.setEnhanced();
}
}
logSerializableTypes(logger, fieldSerializableTypes);
- return new SerializableTypeOracleImpl(fieldSerializableTypes,
- possiblyInstantiatedTypes);
+ return new SerializableTypeOracleImpl(fieldSerializableTypes, possiblyInstantiatedTypes);
}
/**
@@ -924,8 +904,8 @@
*
* The method is exposed using default access to enable testing.
*/
- TypeInfoComputed computeTypeInstantiability(TreeLogger logger, JType type,
- TypePath path, ProblemReport problems) {
+ TypeInfoComputed computeTypeInstantiability(TreeLogger logger, JType type, TypePath path,
+ ProblemReport problems) {
assert (type != null);
if (type.isPrimitive() != null) {
TypeInfoComputed tic = getTypeInfoComputed(type, path, true);
@@ -944,16 +924,14 @@
return tic;
}
- TreeLogger localLogger = logger.branch(TreeLogger.DEBUG,
- classType.getParameterizedQualifiedSourceName(), null);
+ TreeLogger localLogger =
+ logger.branch(TreeLogger.DEBUG, classType.getParameterizedQualifiedSourceName(), null);
JTypeParameter isTypeParameter = classType.isTypeParameter();
if (isTypeParameter != null) {
if (typeParametersInRootTypes.contains(isTypeParameter)) {
- return computeTypeInstantiability(localLogger,
- isTypeParameter.getFirstBound(),
- TypePaths.createTypeParameterInRootPath(path, isTypeParameter),
- problems);
+ return computeTypeInstantiability(localLogger, isTypeParameter.getFirstBound(), TypePaths
+ .createTypeParameterInRootPath(path, isTypeParameter), problems);
}
/*
@@ -971,8 +949,9 @@
if (isWildcard != null) {
boolean success = true;
for (JClassType bound : isWildcard.getUpperBounds()) {
- success &= computeTypeInstantiability(localLogger, bound, path,
- problems).hasInstantiableSubtypes();
+ success &=
+ computeTypeInstantiability(localLogger, bound, path, problems)
+ .hasInstantiableSubtypes();
}
tic = getTypeInfoComputed(classType, path, true);
tic.setInstantiableSubtypes(success);
@@ -982,8 +961,7 @@
JArrayType isArray = classType.isArray();
if (isArray != null) {
- TypeInfoComputed arrayTic = checkArrayInstantiable(localLogger, isArray,
- path, problems);
+ TypeInfoComputed arrayTic = checkArrayInstantiable(localLogger, isArray, path, problems);
assert getTypeInfoComputed(classType, path, false) != null;
return arrayTic;
}
@@ -994,21 +972,21 @@
* our restrictions on RPC. Should be fatal, but I worry users may have
* Object-using code they can't readily get out of the class hierarchy.
*/
- problems.add(classType,
- "In order to produce smaller client-side code, 'Object' is not "
- + "allowed; please use a more specific type", Priority.DEFAULT);
+ problems.add(classType, "In order to produce smaller client-side code, 'Object' is not "
+ + "allowed; please use a more specific type", Priority.DEFAULT);
tic = getTypeInfoComputed(classType, path, true);
tic.setInstantiable(false);
return tic;
}
if (classType.isRawType() != null) {
- localLogger.log(
- TreeLogger.DEBUG,
- "Type '"
- + classType.getQualifiedSourceName()
- + "' should be parameterized to help the compiler produce the smallest code size possible for your module",
- null);
+ localLogger
+ .log(
+ TreeLogger.DEBUG,
+ "Type '"
+ + classType.getQualifiedSourceName()
+ + "' should be parameterized to help the compiler produce the smallest code size possible for your module",
+ null);
}
JClassType originalType = (JClassType) type;
@@ -1016,8 +994,8 @@
// TreeLogger subtypesLogger = localLogger.branch(TreeLogger.DEBUG,
// "Analyzing subclasses:", null);
tic = getTypeInfoComputed(classType, path, true);
- boolean anySubtypes = checkSubtypes(localLogger, originalType,
- tic.getInstantiableTypes(), path, problems);
+ boolean anySubtypes =
+ checkSubtypes(localLogger, originalType, tic.getInstantiableTypes(), path, problems);
if (!tic.isDone()) {
tic.setInstantiableSubtypes(anySubtypes);
tic.setInstantiable(false);
@@ -1035,8 +1013,7 @@
*
* Default access to allow for testing.
*/
- boolean shouldConsiderFieldsForSerialization(JClassType type,
- ProblemReport problems) {
+ boolean shouldConsiderFieldsForSerialization(JClassType type, ProblemReport problems) {
return shouldConsiderFieldsForSerialization(type, typeFilter, problems);
}
@@ -1045,8 +1022,7 @@
*
* @param logger
*/
- private void checkAllSubtypesOfObject(TreeLogger logger, TypePath parent,
- ProblemReport problems) {
+ private void checkAllSubtypesOfObject(TreeLogger logger, TypePath parent, ProblemReport problems) {
if (alreadyCheckedObject) {
return;
}
@@ -1058,33 +1034,31 @@
* serialization to avoid generating false errors due to types that do not
* qualify for serialization and have no serializable subtypes.
*/
- TreeLogger localLogger = logger.branch(TreeLogger.WARN,
- "Checking all subtypes of Object which qualify for serialization", null);
+ TreeLogger localLogger =
+ logger.branch(TreeLogger.WARN,
+ "Checking all subtypes of Object which qualify for serialization", null);
JClassType[] allTypes = typeOracle.getJavaLangObject().getSubtypes();
for (JClassType cls : allTypes) {
if (isDeclaredSerializable(cls)) {
- computeTypeInstantiability(localLogger, cls,
- TypePaths.createSubtypePath(parent, cls,
- typeOracle.getJavaLangObject()), problems);
+ computeTypeInstantiability(localLogger, cls, TypePaths.createSubtypePath(parent, cls,
+ typeOracle.getJavaLangObject()), problems);
}
}
}
- private TypeInfoComputed checkArrayInstantiable(TreeLogger logger,
- JArrayType array, TypePath path, ProblemReport problems) {
+ private TypeInfoComputed checkArrayInstantiable(TreeLogger logger, JArrayType array,
+ TypePath path, ProblemReport problems) {
JType leafType = array.getLeafType();
JWildcardType leafWild = leafType.isWildcard();
if (leafWild != null) {
- JArrayType arrayType = getArrayType(typeOracle, array.getRank(),
- leafWild.getUpperBound());
+ JArrayType arrayType = getArrayType(typeOracle, array.getRank(), leafWild.getUpperBound());
return checkArrayInstantiable(logger, arrayType, path, problems);
}
JClassType leafClass = leafType.isClassOrInterface();
JTypeParameter isLeafTypeParameter = leafType.isTypeParameter();
- if (isLeafTypeParameter != null
- && !typeParametersInRootTypes.contains(isLeafTypeParameter)) {
+ if (isLeafTypeParameter != null && !typeParametersInRootTypes.contains(isLeafTypeParameter)) {
// Don't deal with non root type parameters, but make a TIC entry to
// save time if it recurs. We assume they're indirectly instantiable.
TypeInfoComputed tic = getTypeInfoComputed(array, path, true);
@@ -1109,19 +1083,18 @@
}
tic.setPendingInstantiable();
- TreeLogger branch = logger.branch(TreeLogger.DEBUG,
- "Analyzing component type:", null);
+ TreeLogger branch = logger.branch(TreeLogger.DEBUG, "Analyzing component type:", null);
- TypeInfoComputed leafTic = computeTypeInstantiability(branch, leafType,
- TypePaths.createArrayComponentPath(array, path), problems);
+ TypeInfoComputed leafTic =
+ computeTypeInstantiability(branch, leafType, TypePaths
+ .createArrayComponentPath(array, path), problems);
boolean succeeded = leafTic.hasInstantiableSubtypes();
if (succeeded) {
if (leafClass == null) {
assert leafType.isPrimitive() != null;
markArrayTypesInstantiable(leafType, array.getRank(), path);
} else {
- TreeLogger covariantArrayLogger = logger.branch(TreeLogger.DEBUG,
- "Covariant array types");
+ TreeLogger covariantArrayLogger = logger.branch(TreeLogger.DEBUG, "Covariant array types");
/*
* Compute covariant arrays for arrays of reference types.
@@ -1134,9 +1107,8 @@
}
if (covariantArrayLogger.isLoggable(TreeLogger.DEBUG)) {
- covariantArrayLogger.branch(TreeLogger.DEBUG,
- getArrayType(typeOracle, array.getRank(),
- instantiableType).getParameterizedQualifiedSourceName());
+ covariantArrayLogger.branch(TreeLogger.DEBUG, getArrayType(typeOracle, array.getRank(),
+ instantiableType).getParameterizedQualifiedSourceName());
}
markArrayTypesInstantiable(instantiableType, array.getRank(), path);
@@ -1153,8 +1125,8 @@
* instantiable. As a side-effect it fills in {@link TypeInfoComputed} for all
* necessary types.
*/
- private boolean checkDeclaredFields(TreeLogger logger,
- TypeInfoComputed typeInfo, TypePath parent, ProblemReport problems) {
+ private boolean checkDeclaredFields(TreeLogger logger, TypeInfoComputed typeInfo,
+ TypePath parent, ProblemReport problems) {
JClassType classOrInterface = (JClassType) typeInfo.getType();
if (classOrInterface.isEnum() != null) {
@@ -1169,30 +1141,28 @@
// as infinite expansion can be avoided in the process.
JField[] fields = baseType.getFields();
if (fields.length > 0) {
- TreeLogger localLogger = logger.branch(TreeLogger.DEBUG,
- "Analyzing the fields of type '"
+ TreeLogger localLogger =
+ logger.branch(TreeLogger.DEBUG, "Analyzing the fields of type '"
+ classOrInterface.getParameterizedQualifiedSourceName()
+ "' that qualify for serialization", null);
for (JField field : fields) {
- if (!shouldConsiderForSerialization(localLogger,
- suppressNonStaticFinalFieldWarnings, field)) {
+ if (!shouldConsiderForSerialization(localLogger, suppressNonStaticFinalFieldWarnings, field)) {
continue;
}
- TreeLogger fieldLogger = localLogger.branch(TreeLogger.DEBUG,
- field.toString(), null);
+ TreeLogger fieldLogger = localLogger.branch(TreeLogger.DEBUG, field.toString(), null);
JType fieldType = field.getType();
TypePath path = TypePaths.createFieldPath(parent, field);
if (typeInfo.isManuallySerializable()
&& fieldType.getLeafType() == typeOracle.getJavaLangObject()) {
checkAllSubtypesOfObject(fieldLogger.branch(TreeLogger.WARN,
- "Object was reached from a manually serializable type", null),
- path, problems);
+ "Object was reached from a manually serializable type", null), path, problems);
} else {
- allSucceeded &= computeTypeInstantiability(fieldLogger, fieldType,
- path, problems).hasInstantiableSubtypes();
+ allSucceeded &=
+ computeTypeInstantiability(fieldLogger, fieldType, path, problems)
+ .hasInstantiableSubtypes();
}
}
}
@@ -1221,15 +1191,13 @@
*/
checkAllSubtypesOfObject(logger, parent, problems);
} else {
- TreeLogger paramsLogger = logger.branch(TreeLogger.DEBUG,
- "Checking parameters of '"
+ TreeLogger paramsLogger =
+ logger.branch(TreeLogger.DEBUG, "Checking parameters of '"
+ isParameterized.getParameterizedQualifiedSourceName() + "'");
for (JTypeParameter param : isParameterized.getBaseType().getTypeParameters()) {
- if (!checkTypeArgument(paramsLogger, isParameterized.getBaseType(),
- param.getOrdinal(),
- isParameterized.getTypeArgs()[param.getOrdinal()], parent,
- problems)) {
+ if (!checkTypeArgument(paramsLogger, isParameterized.getBaseType(), param.getOrdinal(),
+ isParameterized.getTypeArgs()[param.getOrdinal()], parent, problems)) {
return false;
}
}
@@ -1249,9 +1217,9 @@
}
boolean superTypeOk = false;
- superTypeOk = checkSubtype(logger, superType, originalType,
- TypePaths.createSupertypePath(parent, superType, classOrInterface),
- problems);
+ superTypeOk =
+ checkSubtype(logger, superType, originalType, TypePaths.createSupertypePath(parent,
+ superType, classOrInterface), problems);
/*
* If my super type did not check out, then I am not instantiable and we
@@ -1274,17 +1242,15 @@
private boolean checkSubtypes(TreeLogger logger, JClassType originalType,
Set<JClassType> instSubtypes, TypePath path, ProblemReport problems) {
JClassType baseType = getBaseType(originalType);
- TreeLogger computationLogger = logger.branch(TreeLogger.DEBUG,
- "Finding possibly instantiable subtypes");
- List<JClassType> candidates = getPossiblyInstantiableSubtypes(
- computationLogger, baseType, problems);
+ TreeLogger computationLogger =
+ logger.branch(TreeLogger.DEBUG, "Finding possibly instantiable subtypes");
+ List<JClassType> candidates =
+ getPossiblyInstantiableSubtypes(computationLogger, baseType, problems);
boolean anySubtypes = false;
- TreeLogger verificationLogger = logger.branch(TreeLogger.DEBUG,
- "Verifying instantiability");
+ TreeLogger verificationLogger = logger.branch(TreeLogger.DEBUG, "Verifying instantiability");
for (JClassType candidate : candidates) {
- if (getBaseType(candidate) == baseType
- && originalType.isRawType() == null) {
+ if (getBaseType(candidate) == baseType && originalType.isRawType() == null) {
// Don't rely on the constrainer when we have perfect information.
candidate = originalType;
} else {
@@ -1298,8 +1264,7 @@
continue;
}
- TypePath subtypePath = TypePaths.createSubtypePath(path, candidate,
- originalType);
+ TypePath subtypePath = TypePaths.createSubtypePath(path, candidate, originalType);
TypeInfoComputed tic = getTypeInfoComputed(candidate, subtypePath, true);
if (tic.isDone()) {
if (tic.isInstantiable()) {
@@ -1314,10 +1279,11 @@
}
tic.setPendingInstantiable();
- TreeLogger subtypeLogger = verificationLogger.branch(TreeLogger.DEBUG,
- candidate.getParameterizedQualifiedSourceName());
- boolean instantiable = checkSubtype(subtypeLogger, candidate,
- originalType, subtypePath, problems);
+ TreeLogger subtypeLogger =
+ verificationLogger.branch(TreeLogger.DEBUG, candidate
+ .getParameterizedQualifiedSourceName());
+ boolean instantiable =
+ checkSubtype(subtypeLogger, candidate, originalType, subtypePath, problems);
anySubtypes |= instantiable;
tic.setInstantiable(instantiable);
@@ -1353,13 +1319,12 @@
* <code>paramIndex</code>th type argument is a subtype of
* <code>typeArg</code>.
*/
- private boolean checkTypeArgument(TreeLogger logger, JGenericType baseType,
- int paramIndex, JClassType typeArg, TypePath parent,
- ProblemReport problems) {
+ private boolean checkTypeArgument(TreeLogger logger, JGenericType baseType, int paramIndex,
+ JClassType typeArg, TypePath parent, ProblemReport problems) {
JWildcardType isWildcard = typeArg.isWildcard();
if (isWildcard != null) {
- return checkTypeArgument(logger, baseType, paramIndex,
- isWildcard.getUpperBound(), parent, problems);
+ return checkTypeArgument(logger, baseType, paramIndex, isWildcard.getUpperBound(), parent,
+ problems);
}
JArrayType typeArgAsArray = typeArg.isArray();
@@ -1368,59 +1333,50 @@
if (parameterOfTypeArgArray != null) {
JGenericType declaringClass = parameterOfTypeArgArray.getDeclaringClass();
if (declaringClass != null) {
- TypeParameterFlowInfo flowInfoForArrayParam = getFlowInfo(
- declaringClass, parameterOfTypeArgArray.getOrdinal());
- TypeParameterFlowInfo otherFlowInfo = getFlowInfo(baseType,
- paramIndex);
+ TypeParameterFlowInfo flowInfoForArrayParam =
+ getFlowInfo(declaringClass, parameterOfTypeArgArray.getOrdinal());
+ TypeParameterFlowInfo otherFlowInfo = getFlowInfo(baseType, paramIndex);
if (otherFlowInfo.getExposure() >= 0
&& otherFlowInfo.isTransitivelyAffectedBy(flowInfoForArrayParam)) {
problems.add(baseType, "Cannot serialize type '"
+ baseType.getParameterizedQualifiedSourceName()
+ "' when given an argument of type '"
+ typeArg.getParameterizedQualifiedSourceName()
- + "' because it appears to require serializing arrays "
- + "of unbounded dimension", Priority.DEFAULT);
+ + "' because it appears to require serializing arrays " + "of unbounded dimension",
+ Priority.DEFAULT);
return false;
}
}
}
}
- TypePath path = TypePaths.createTypeArgumentPath(parent, baseType,
- paramIndex, typeArg);
+ TypePath path = TypePaths.createTypeArgumentPath(parent, baseType, paramIndex, typeArg);
int exposure = getTypeParameterExposure(baseType, paramIndex);
switch (exposure) {
case TypeParameterExposureComputer.EXPOSURE_DIRECT: {
- TreeLogger branch = logger.branch(
- TreeLogger.DEBUG,
- "Checking type argument "
- + paramIndex
- + " of type '"
+ TreeLogger branch =
+ logger.branch(TreeLogger.DEBUG, "Checking type argument " + paramIndex + " of type '"
+ baseType.getParameterizedQualifiedSourceName()
+ "' because it is directly exposed in this type or in one of its subtypes");
- return computeTypeInstantiability(branch, typeArg, path, problems).hasInstantiableSubtypes()
+ return computeTypeInstantiability(branch, typeArg, path, problems)
+ .hasInstantiableSubtypes()
|| mightNotBeExposed(baseType, paramIndex);
}
case TypeParameterExposureComputer.EXPOSURE_NONE:
// Ignore this argument
- logger.log(TreeLogger.DEBUG, "Ignoring type argument " + paramIndex
- + " of type '" + baseType.getParameterizedQualifiedSourceName()
+ logger.log(TreeLogger.DEBUG, "Ignoring type argument " + paramIndex + " of type '"
+ + baseType.getParameterizedQualifiedSourceName()
+ "' because it is not exposed in this or any subtype");
return true;
default: {
assert (exposure >= TypeParameterExposureComputer.EXPOSURE_MIN_BOUNDED_ARRAY);
- problems.add(
- getArrayType(typeOracle, exposure, typeArg),
- "Checking type argument "
- + paramIndex
- + " of type '"
- + baseType.getParameterizedQualifiedSourceName()
- + "' because it is exposed as an array with a maximum dimension of "
- + exposure + " in this type or one of its subtypes",
- Priority.AUXILIARY);
- return computeTypeInstantiability(logger,
- getArrayType(typeOracle, exposure, typeArg), path, problems).hasInstantiableSubtypes()
+ problems.add(getArrayType(typeOracle, exposure, typeArg), "Checking type argument "
+ + paramIndex + " of type '" + baseType.getParameterizedQualifiedSourceName()
+ + "' because it is exposed as an array with a maximum dimension of " + exposure
+ + " in this type or one of its subtypes", Priority.AUXILIARY);
+ return computeTypeInstantiability(logger, getArrayType(typeOracle, exposure, typeArg),
+ path, problems).hasInstantiableSubtypes()
|| mightNotBeExposed(baseType, paramIndex);
}
}
@@ -1438,15 +1394,14 @@
}
private TypeParameterFlowInfo getFlowInfo(JGenericType type, int index) {
- return typeParameterExposureComputer.computeTypeParameterExposure(type,
- index);
+ return typeParameterExposureComputer.computeTypeParameterExposure(type, index);
}
/**
* Returns the subtypes of a given base type as parameterized by wildcards.
*/
- private List<JClassType> getPossiblyInstantiableSubtypes(TreeLogger logger,
- JClassType baseType, ProblemReport problems) {
+ private List<JClassType> getPossiblyInstantiableSubtypes(TreeLogger logger, JClassType baseType,
+ ProblemReport problems) {
assert (baseType == getBaseType(baseType));
List<JClassType> possiblyInstantiableTypes = new ArrayList<JClassType>();
@@ -1483,23 +1438,21 @@
JClassType subtype = candidates.get(i);
String worstMessage = problems.getWorstMessageForType(subtype);
if (worstMessage == null) {
- possibilities[i] = " subtype "
- + subtype.getParameterizedQualifiedSourceName()
- + " is not instantiable";
+ possibilities[i] =
+ " subtype " + subtype.getParameterizedQualifiedSourceName()
+ + " is not instantiable";
} else {
// message with have the form "FQCN some-problem-description"
possibilities[i] = " subtype " + worstMessage;
}
}
problems.add(baseType, baseType.getParameterizedQualifiedSourceName()
- + " has no available instantiable subtypes.", Priority.DEFAULT,
- possibilities);
+ + " has no available instantiable subtypes.", Priority.DEFAULT, possibilities);
}
return possiblyInstantiableTypes;
}
- private TypeInfoComputed getTypeInfoComputed(JType type, TypePath path,
- boolean createIfNeeded) {
+ private TypeInfoComputed getTypeInfoComputed(JType type, TypePath path, boolean createIfNeeded) {
TypeInfoComputed tic = typeToTypeInfoComputed.get(type);
if (tic == null && createIfNeeded) {
tic = new TypeInfoComputed(type, path);
@@ -1546,15 +1499,13 @@
if (logOutputWriter != null) {
// Route the TreeLogger output to an output stream.
- PrintWriterTreeLogger printWriterTreeLogger = new PrintWriterTreeLogger(
- logOutputWriter);
+ PrintWriterTreeLogger printWriterTreeLogger = new PrintWriterTreeLogger(logOutputWriter);
printWriterTreeLogger.setMaxDetail(TreeLogger.ALL);
logger = printWriterTreeLogger;
}
if (logger.isLoggable(TreeLogger.DEBUG)) {
- logger.log(TreeLogger.DEBUG, "Reachable types computed on: "
- + new Date().toString());
+ logger.log(TreeLogger.DEBUG, "Reachable types computed on: " + new Date().toString());
}
Set<JType> keySet = typeToTypeInfoComputed.keySet();
JType[] types = keySet.toArray(new JType[0]);
@@ -1564,10 +1515,9 @@
TypeInfoComputed tic = typeToTypeInfoComputed.get(type);
assert (tic != null);
- TreeLogger typeLogger = logger.branch(TreeLogger.DEBUG,
- tic.getType().getParameterizedQualifiedSourceName());
- TreeLogger serializationStatus = typeLogger.branch(TreeLogger.DEBUG,
- "Serialization status");
+ TreeLogger typeLogger =
+ logger.branch(TreeLogger.DEBUG, tic.getType().getParameterizedQualifiedSourceName());
+ TreeLogger serializationStatus = typeLogger.branch(TreeLogger.DEBUG, "Serialization status");
if (tic.isInstantiable()) {
serializationStatus.branch(TreeLogger.DEBUG, "Instantiable");
} else {
@@ -1593,21 +1543,18 @@
* Mark arrays of <code>leafType</code> as instantiable, for arrays of
* dimension up to <code>maxRank</code>.
*/
- private void markArrayTypesInstantiable(JType leafType, int maxRank,
- TypePath path) {
+ private void markArrayTypesInstantiable(JType leafType, int maxRank, TypePath path) {
for (int rank = 1; rank <= maxRank; ++rank) {
JArrayType covariantArray = getArrayType(typeOracle, rank, leafType);
- TypeInfoComputed covariantArrayTic = getTypeInfoComputed(covariantArray,
- path, true);
+ TypeInfoComputed covariantArrayTic = getTypeInfoComputed(covariantArray, path, true);
covariantArrayTic.setInstantiable(true);
}
}
- private boolean maybeInstantiable(TreeLogger logger, JClassType type,
- ProblemReport problems) {
- boolean success = canBeInstantiated(type, problems)
- && shouldConsiderFieldsForSerialization(type, problems);
+ private boolean maybeInstantiable(TreeLogger logger, JClassType type, ProblemReport problems) {
+ boolean success =
+ canBeInstantiated(type, problems) && shouldConsiderFieldsForSerialization(type, problems);
if (success) {
if (logger.isLoggable(TreeLogger.DEBUG)) {
logger.log(TreeLogger.DEBUG, type.getParameterizedQualifiedSourceName()
diff --git a/user/src/com/google/gwt/user/rebind/rpc/SerializationUtils.java b/user/src/com/google/gwt/user/rebind/rpc/SerializationUtils.java
index f471f85..17cc6a0 100644
--- a/user/src/com/google/gwt/user/rebind/rpc/SerializationUtils.java
+++ b/user/src/com/google/gwt/user/rebind/rpc/SerializationUtils.java
@@ -45,7 +45,8 @@
};
static final String GENERATED_FIELD_SERIALIZER_SUFFIX = "_FieldSerializer";
static final String TYPE_SERIALIZER_SUFFIX = "_TypeSerializer";
- static final Set<String> TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES = new HashSet<String>();
+ static final Set<String> TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES =
+ new HashSet<String>();
static {
TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add("java.lang.Boolean");
@@ -65,7 +66,8 @@
* Work around for incompatible type hierarchy (and therefore signature)
* between JUnit3 and JUnit4.
*/
- TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add("junit.framework.AssertionFailedError");
+ TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES
+ .add("junit.framework.AssertionFailedError");
}
/**
@@ -80,35 +82,33 @@
if (primitiveType != null) {
return primitiveType.getJNISignature();
}
-
+
JArrayType arrayType = type.isArray();
if (arrayType != null) {
JType component = arrayType.getComponentType();
if (component.isClassOrInterface() != null) {
- return "[L" + getRpcTypeName(arrayType.getComponentType())
- + ";";
+ return "[L" + getRpcTypeName(arrayType.getComponentType()) + ";";
} else {
return "[" + getRpcTypeName(arrayType.getComponentType());
}
}
-
+
JParameterizedType parameterizedType = type.isParameterized();
if (parameterizedType != null) {
return getRpcTypeName(parameterizedType.getBaseType());
}
-
+
JClassType classType = type.isClassOrInterface();
assert (classType != null);
-
+
JClassType enclosingType = classType.getEnclosingType();
if (enclosingType != null) {
- return getRpcTypeName(enclosingType) + "$"
- + classType.getSimpleSourceName();
+ return getRpcTypeName(enclosingType) + "$" + classType.getSimpleSourceName();
}
-
+
return classType.getQualifiedSourceName();
}
-
+
/**
* Returns the set of fields that are serializable for a given class type.
* This method does not consider any superclass fields.
@@ -117,16 +117,15 @@
* @param classType the class for which we want serializable fields
* @return array of fields that meet the serialization criteria
*/
- public static JField[] getSerializableFields(TypeOracle typeOracle,
- JClassType classType) {
+ public static JField[] getSerializableFields(TypeOracle typeOracle, JClassType classType) {
assert (classType != null);
List<JField> fields = new ArrayList<JField>();
JField[] declFields = classType.getFields();
assert (declFields != null);
for (JField field : declFields) {
- if (SerializableTypeOracleBuilder.shouldConsiderForSerialization(
- TreeLogger.NULL, true, field)) {
+ if (SerializableTypeOracleBuilder
+ .shouldConsiderForSerialization(TreeLogger.NULL, true, field)) {
fields.add(field);
}
}
@@ -144,8 +143,8 @@
* @return the fully qualified name of the field serializer for the given type
*/
static String getFieldSerializerName(TypeOracle typeOracle, JType type) {
- JClassType customSerializer = SerializableTypeOracleBuilder.findCustomFieldSerializer(
- typeOracle, type);
+ JClassType customSerializer =
+ SerializableTypeOracleBuilder.findCustomFieldSerializer(typeOracle, type);
if (customSerializer != null) {
return customSerializer.getQualifiedSourceName();
}
@@ -168,8 +167,7 @@
try {
generateSerializationSignature(typeOracle, type, crc);
} catch (UnsupportedEncodingException e) {
- throw new RuntimeException(
- "Could not compute the serialization signature", e);
+ throw new RuntimeException("Could not compute the serialization signature", e);
}
return Long.toString(crc.getValue());
@@ -179,8 +177,9 @@
* Returns the name of the generated field serializer.
*/
static String getStandardSerializerName(JClassType classType) {
- String[] name = Shared.synthesizeTopLevelClassName(classType,
- SerializationUtils.GENERATED_FIELD_SERIALIZER_SUFFIX);
+ String[] name =
+ Shared.synthesizeTopLevelClassName(classType,
+ SerializationUtils.GENERATED_FIELD_SERIALIZER_SUFFIX);
if (name[0].length() > 0) {
String serializerName = name[0] + "." + name[1];
if (SerializableTypeOracleBuilder.isInStandardJavaPackage(classType.getQualifiedSourceName())) {
@@ -189,8 +188,7 @@
* CompilingClassLoader will fail to resolve references to the generated
* code.
*/
- serializerName = "com.google.gwt.user.client.rpc.core."
- + serializerName;
+ serializerName = "com.google.gwt.user.client.rpc.core." + serializerName;
}
return serializerName;
@@ -213,8 +211,7 @@
+ " is not a service interface");
}
- String[] name = Shared.synthesizeTopLevelClassName(serviceIntf,
- TYPE_SERIALIZER_SUFFIX);
+ String[] name = Shared.synthesizeTopLevelClassName(serviceIntf, TYPE_SERIALIZER_SUFFIX);
if (name[0].length() > 0) {
return name[0] + "." + name[1];
} else {
@@ -235,26 +232,24 @@
+ " is not a service interface");
}
- String[] name = Shared.synthesizeTopLevelClassName(serviceIntf,
- TYPE_SERIALIZER_SUFFIX);
+ String[] name = Shared.synthesizeTopLevelClassName(serviceIntf, TYPE_SERIALIZER_SUFFIX);
return name[1];
}
- private static boolean excludeImplementationFromSerializationSignature(
- JType instanceType) {
- if (TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.contains(instanceType.getQualifiedSourceName())) {
+ private static boolean excludeImplementationFromSerializationSignature(JType instanceType) {
+ if (TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.contains(instanceType
+ .getQualifiedSourceName())) {
return true;
}
return false;
}
- private static void generateSerializationSignature(TypeOracle typeOracle,
- JType type, CRC32 crc) throws UnsupportedEncodingException {
+ private static void generateSerializationSignature(TypeOracle typeOracle, JType type, CRC32 crc)
+ throws UnsupportedEncodingException {
JParameterizedType parameterizedType = type.isParameterized();
if (parameterizedType != null) {
- generateSerializationSignature(typeOracle,
- parameterizedType.getRawType(), crc);
+ generateSerializationSignature(typeOracle, parameterizedType.getRawType(), crc);
return;
}
@@ -266,14 +261,13 @@
return;
}
- JClassType customSerializer = SerializableTypeOracleBuilder.findCustomFieldSerializer(
- typeOracle, type);
+ JClassType customSerializer =
+ SerializableTypeOracleBuilder.findCustomFieldSerializer(typeOracle, type);
if (customSerializer != null) {
generateSerializationSignature(typeOracle, customSerializer, crc);
} else if (type.isArray() != null) {
JArrayType isArray = type.isArray();
- generateSerializationSignature(typeOracle, isArray.getComponentType(),
- crc);
+ generateSerializationSignature(typeOracle, isArray.getComponentType(), crc);
} else if (type.isClassOrInterface() != null) {
JClassType isClassOrInterface = type.isClassOrInterface();
JField[] fields = getSerializableFields(typeOracle, isClassOrInterface);
@@ -281,8 +275,7 @@
assert (field != null);
crc.update(field.getName().getBytes(Util.DEFAULT_ENCODING));
- crc.update(getRpcTypeName(field.getType()).getBytes(
- Util.DEFAULT_ENCODING));
+ crc.update(getRpcTypeName(field.getType()).getBytes(Util.DEFAULT_ENCODING));
}
JClassType superClass = isClassOrInterface.getSuperclass();
diff --git a/user/src/com/google/gwt/user/rebind/rpc/ServiceInterfaceProxyGenerator.java b/user/src/com/google/gwt/user/rebind/rpc/ServiceInterfaceProxyGenerator.java
index 67b0c31..b84941e 100644
--- a/user/src/com/google/gwt/user/rebind/rpc/ServiceInterfaceProxyGenerator.java
+++ b/user/src/com/google/gwt/user/rebind/rpc/ServiceInterfaceProxyGenerator.java
@@ -29,39 +29,39 @@
* {@link com.google.gwt.user.client.rpc.RemoteService RemoteService} interface.
*/
public class ServiceInterfaceProxyGenerator extends GeneratorExt {
-
+
@Override
public RebindResult generateIncrementally(TreeLogger logger, GeneratorContextExt ctx,
String requestedClass) throws UnableToCompleteException {
-
+
TypeOracle typeOracle = ctx.getTypeOracle();
assert (typeOracle != null);
JClassType remoteService = typeOracle.findType(requestedClass);
if (remoteService == null) {
- logger.log(TreeLogger.ERROR, "Unable to find metadata for type '"
- + requestedClass + "'", null);
+ logger.log(TreeLogger.ERROR, "Unable to find metadata for type '" + requestedClass + "'",
+ null);
throw new UnableToCompleteException();
}
if (remoteService.isInterface() == null) {
- logger.log(TreeLogger.ERROR, remoteService.getQualifiedSourceName()
- + " is not an interface", null);
+ logger.log(TreeLogger.ERROR, remoteService.getQualifiedSourceName() + " is not an interface",
+ null);
throw new UnableToCompleteException();
}
ProxyCreator proxyCreator = createProxyCreator(remoteService);
- TreeLogger proxyLogger = logger.branch(TreeLogger.DEBUG,
- "Generating client proxy for remote service interface '"
+ TreeLogger proxyLogger =
+ logger.branch(TreeLogger.DEBUG, "Generating client proxy for remote service interface '"
+ remoteService.getQualifiedSourceName() + "'", null);
String returnTypeName = proxyCreator.create(proxyLogger, ctx);
-
+
/*
* Return with RebindStatus.USE_PARTIAL_CACHED, since we are implementing an
* incremental scheme, which allows us to use a mixture of previously cached
- * and newly generated compilation units and artifacts. For example, the
+ * and newly generated compilation units and artifacts. For example, the
* field serializers only need to be generated fresh if their source type
* has changed (or if no previously cached version exists).
*/
diff --git a/user/src/com/google/gwt/user/rebind/rpc/Shared.java b/user/src/com/google/gwt/user/rebind/rpc/Shared.java
index 03baca4..4c710d1 100644
--- a/user/src/com/google/gwt/user/rebind/rpc/Shared.java
+++ b/user/src/com/google/gwt/user/rebind/rpc/Shared.java
@@ -37,7 +37,8 @@
* Property used to control whether or not the RPC system will emit warnings
* when a type has final fields.
*/
- private static final String RPC_PROP_SUPPRESS_NON_STATIC_FINAL_FIELD_WARNINGS = "gwt.suppressNonStaticFinalFieldWarnings";
+ private static final String RPC_PROP_SUPPRESS_NON_STATIC_FINAL_FIELD_WARNINGS =
+ "gwt.suppressNonStaticFinalFieldWarnings";
/**
* Multi-valued configuration property used to list classes that are
@@ -55,12 +56,13 @@
static String capitalize(String name) {
return name.substring(0, 1).toUpperCase(Locale.US) + name.substring(1);
}
-
+
/**
- * Returns a Set of names of classes that may be enhanced with extra server-only fields.
+ * Returns a Set of names of classes that may be enhanced with extra
+ * server-only fields.
*
- * @param propertyOracle The propertyOracle used to access the relevant configuration
- * property.
+ * @param propertyOracle The propertyOracle used to access the relevant
+ * configuration property.
* @return a Set of Strings, or null.
*/
static Set<String> getEnhancedTypes(PropertyOracle propertyOracle) {
@@ -153,16 +155,14 @@
* otherwise <code>false</code>.
*/
static boolean typeNeedsCast(JType type) {
- return type.isPrimitive() == null
- && !type.getQualifiedSourceName().equals("java.lang.String")
+ return type.isPrimitive() == null && !type.getQualifiedSourceName().equals("java.lang.String")
&& !type.getQualifiedSourceName().equals("java.lang.Object");
}
- private static boolean getBooleanProperty(TreeLogger logger,
- PropertyOracle propertyOracle, String propertyName, boolean defaultValue) {
+ private static boolean getBooleanProperty(TreeLogger logger, PropertyOracle propertyOracle,
+ String propertyName, boolean defaultValue) {
try {
- SelectionProperty prop
- = propertyOracle.getSelectionProperty(logger, propertyName);
+ SelectionProperty prop = propertyOracle.getSelectionProperty(logger, propertyName);
String propVal = prop.getCurrentValue();
if (propVal != null && propVal.length() > 0) {
return Boolean.valueOf(propVal);
diff --git a/user/src/com/google/gwt/user/rebind/rpc/TypeConstrainer.java b/user/src/com/google/gwt/user/rebind/rpc/TypeConstrainer.java
index 7a20c4a..bafa3e2 100644
--- a/user/src/com/google/gwt/user/rebind/rpc/TypeConstrainer.java
+++ b/user/src/com/google/gwt/user/rebind/rpc/TypeConstrainer.java
@@ -114,9 +114,9 @@
/**
* Return a subtype of <code>subType</code> that includes all values in both
- * <code>subType</code> and <code>superType</code>. The returned type
- * must have the same base type as <code>subType</code>. If there are
- * definitely no such values, return <code>null</code>.
+ * <code>subType</code> and <code>superType</code>. The returned type must
+ * have the same base type as <code>subType</code>. If there are definitely no
+ * such values, return <code>null</code>.
*/
public JClassType constrainTypeBy(JClassType subType, JClassType superType) {
JParameterizedType superAsParameterized = superType.isParameterized();
@@ -130,11 +130,12 @@
// Replace each wildcard in the subType with a fresh type variable.
// These type variables will be the ones that are constrained.
Map<JTypeParameter, JClassType> constraints = new HashMap<JTypeParameter, JClassType>();
- JClassType subWithWildcardsReplaced = replaceWildcardsWithFreshTypeVariables(
- subType, constraints);
+ JClassType subWithWildcardsReplaced =
+ replaceWildcardsWithFreshTypeVariables(subType, constraints);
// Rewrite subType so that it has the same base type as superType.
- JParameterizedType subAsParameterized = subWithWildcardsReplaced.asParameterizationOf(superAsParameterized.getBaseType());
+ JParameterizedType subAsParameterized =
+ subWithWildcardsReplaced.asParameterizationOf(superAsParameterized.getBaseType());
if (subAsParameterized == null) {
// The subtype's base does not inherit from the supertype's base,
// so again no constraint will be possible.
@@ -153,11 +154,10 @@
/**
* Check whether two types can have any values in common. The
- * <code>constraints</code> field holds known constraints for type
- * parameters that appear in <code>type1</code>; this method may take
- * advantage of those constraints in its decision, and it may tighten them so
- * long as the tightening does not reject any values from the overlap of the
- * two types.
+ * <code>constraints</code> field holds known constraints for type parameters
+ * that appear in <code>type1</code>; this method may take advantage of those
+ * constraints in its decision, and it may tighten them so long as the
+ * tightening does not reject any values from the overlap of the two types.
*
* As an invariant, no key in <code>constraints</code> may occur inside any
* value in <code>constraints</code>.
@@ -167,18 +167,15 @@
* overlaps simplifies the algorithm but returns true more often than it has
* to.
*/
- boolean typesMatch(JClassType type1, JClassType type2,
- Map<JTypeParameter, JClassType> constraints) {
+ boolean typesMatch(JClassType type1, JClassType type2, Map<JTypeParameter, JClassType> constraints) {
JGenericType type1Generic = type1.isGenericType();
if (type1Generic != null) {
- return typesMatch(type1Generic.asParameterizedByWildcards(), type2,
- constraints);
+ return typesMatch(type1Generic.asParameterizedByWildcards(), type2, constraints);
}
JGenericType type2Generic = type2.isGenericType();
if (type2Generic != null) {
- return typesMatch(type1, type2Generic.asParameterizedByWildcards(),
- constraints);
+ return typesMatch(type1, type2Generic.asParameterizedByWildcards(), constraints);
}
JWildcardType type1Wild = type1.isWildcard();
@@ -193,23 +190,21 @@
JRawType type1Raw = type1.isRawType();
if (type1Raw != null) {
- return typesMatch(type1Raw.asParameterizedByWildcards(), type2,
- constraints);
+ return typesMatch(type1Raw.asParameterizedByWildcards(), type2, constraints);
}
JRawType type2Raw = type2.isRawType();
if (type2Raw != null) {
- return typesMatch(type1, type2Raw.asParameterizedByWildcards(),
- constraints);
+ return typesMatch(type1, type2Raw.asParameterizedByWildcards(), constraints);
}
// The following assertions are known to be true, given the tests above.
-// assert (type1Generic == null);
-// assert (type2Generic == null);
-// assert (type1Wild == null);
-// assert (type2Wild == null);
-// assert (type1Raw == null);
-// assert (type2Raw == null);
+ // assert (type1Generic == null);
+ // assert (type2Generic == null);
+ // assert (type1Wild == null);
+ // assert (type2Wild == null);
+ // assert (type1Raw == null);
+ // assert (type2Raw == null);
if (type1 == type2) {
return true;
@@ -254,8 +249,7 @@
JArrayType type1Array = type1.isArray();
JArrayType type2Array = type2.isArray();
if (type1Array != null && type2Array != null) {
- if (typesMatch(type1Array.getComponentType(),
- type2Array.getComponentType(), constraints)) {
+ if (typesMatch(type1Array.getComponentType(), type2Array.getComponentType(), constraints)) {
return true;
}
}
@@ -266,8 +260,7 @@
JParameterizedType type1Parameterized = type1.isParameterized();
JParameterizedType type2Parameterized = type2.isParameterized();
- if (baseType1 == baseType2 && type1Parameterized != null
- && type2Parameterized != null) {
+ if (baseType1 == baseType2 && type1Parameterized != null && type2Parameterized != null) {
// type1 and type2 are parameterized types with the same base type;
// compare their arguments
JClassType[] args1 = type1Parameterized.getTypeArgs();
@@ -298,8 +291,7 @@
* The same as {@link #typesMatch(JClassType, JClassType, Map)}, but
* additionally support primitive types as well as class types.
*/
- boolean typesMatch(JType type1, JType type2,
- Map<JTypeParameter, JClassType> constraints) {
+ boolean typesMatch(JType type1, JType type2, Map<JTypeParameter, JClassType> constraints) {
if (type1 == type2) {
// This covers the case where both are primitives
return true;
@@ -307,8 +299,7 @@
JClassType type1Class = type1.isClassOrInterface();
JClassType type2Class = type2.isClassOrInterface();
- if (type1Class != null && type2Class != null
- && typesMatch(type1Class, type2Class, constraints)) {
+ if (type1Class != null && type2Class != null && typesMatch(type1Class, type2Class, constraints)) {
return true;
}
@@ -316,8 +307,8 @@
}
/**
- * Replace all wildcards in <code>type</code> with a fresh type variable.
- * For each type variable created, add an entry in <code>constraints</code>
+ * Replace all wildcards in <code>type</code> with a fresh type variable. For
+ * each type variable created, add an entry in <code>constraints</code>
* mapping the type variable to its upper bound.
*/
private JClassType replaceWildcardsWithFreshTypeVariables(JClassType type,
@@ -327,9 +318,12 @@
@Override
public void endVisit(JWildcardType wildcardType) {
// TODO: fix this to not assume the typemodel types.
- com.google.gwt.dev.javac.typemodel.JTypeParameter newParam = new com.google.gwt.dev.javac.typemodel.JTypeParameter(
- "TP$" + freshTypeVariableCounter++, -1);
- newParam.setBounds(new com.google.gwt.dev.javac.typemodel.JClassType[]{(com.google.gwt.dev.javac.typemodel.JClassType) typeOracle.getJavaLangObject()});
+ com.google.gwt.dev.javac.typemodel.JTypeParameter newParam =
+ new com.google.gwt.dev.javac.typemodel.JTypeParameter("TP$"
+ + freshTypeVariableCounter++, -1);
+ newParam
+ .setBounds(new com.google.gwt.dev.javac.typemodel.JClassType[] {(com.google.gwt.dev.javac.typemodel.JClassType) typeOracle
+ .getJavaLangObject()});
constraints.put(newParam, wildcardType.getUpperBound());
replacement = newParam;
}
@@ -340,21 +334,20 @@
/**
* Substitute all occurrences in <code>type</code> of type parameters in
- * <code>constraints</code> for a wildcard bounded by the parameter's entry
- * in <code>constraints</code>. If the argument is <code>null</code>,
- * return <code>null</code>.
+ * <code>constraints</code> for a wildcard bounded by the parameter's entry in
+ * <code>constraints</code>. If the argument is <code>null</code>, return
+ * <code>null</code>.
*/
- private JClassType substitute(JClassType type,
- final Map<JTypeParameter, JClassType> constraints) {
+ private JClassType substitute(JClassType type, final Map<JTypeParameter, JClassType> constraints) {
JModTypeVisitor substituter = new JModTypeVisitor() {
@Override
public void endVisit(JTypeParameter param) {
JClassType constr = constraints.get(param);
if (constr != null) {
- // further transform the substituted type recursively
+ // further transform the substituted type recursively
replacement = transform(constr);
}
- }
+ }
};
return substituter.transform(type);
}
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 cf93f8f..46edd5b 100644
--- a/user/src/com/google/gwt/user/rebind/rpc/TypeHierarchyUtils.java
+++ b/user/src/com/google/gwt/user/rebind/rpc/TypeHierarchyUtils.java
@@ -35,20 +35,18 @@
/**
* Returns <code>true</code> if the type directly implements the specified
- * interface. The test is done on erased types; any paramaterizations
- * supplied in the arguments are ignored.
+ * interface. The test is done on erased types; any paramaterizations supplied
+ * in the arguments are ignored.
*
* @param type type to check
* @param intf interface to look for
* @return <code>true</code> if the type directly implements the specified
* interface
*/
- public static boolean directlyImplementsInterface(JClassType type,
- JClassType intf) {
+ public static boolean directlyImplementsInterface(JClassType type, JClassType intf) {
type = type.getErasedType();
intf = intf.getErasedType();
- return directlyImplementsInterfaceRecursive(new HashSet<JClassType>(),
- type, intf);
+ return directlyImplementsInterfaceRecursive(new HashSet<JClassType>(), type, intf);
}
/**
@@ -59,8 +57,8 @@
* @param leaves the set of serializable leaf types
* @return all types on the path from the root type to the serializable leaves
*/
- public static List<JClassType> getAllTypesBetweenRootTypeAndLeaves(
- JClassType root, Collection<JClassType> leaves) {
+ public static List<JClassType> getAllTypesBetweenRootTypeAndLeaves(JClassType root,
+ Collection<JClassType> leaves) {
Map<JClassType, List<JClassType>> adjList = getInvertedTypeHierarchy(root.getErasedType());
Set<JClassType> types = new HashSet<JClassType>();
@@ -92,8 +90,8 @@
return immediateSubtypes;
}
- private static void addEdge(Map<JClassType, List<JClassType>> adjList,
- JClassType subclass, JClassType clazz) {
+ private static void addEdge(Map<JClassType, List<JClassType>> adjList, JClassType subclass,
+ JClassType clazz) {
List<JClassType> edges = adjList.get(subclass);
if (edges == null) {
edges = new ArrayList<JClassType>();
@@ -120,8 +118,8 @@
}
}
- private static boolean directlyImplementsInterfaceRecursive(
- Set<JClassType> seen, JClassType clazz, JClassType intf) {
+ private static boolean directlyImplementsInterfaceRecursive(Set<JClassType> seen,
+ JClassType clazz, JClassType intf) {
assert (clazz.getErasedType() == clazz);
assert (intf.getErasedType() == intf);
@@ -149,8 +147,7 @@
* Given a root type return an adjacency list that is the inverted type
* hierarchy.
*/
- private static Map<JClassType, List<JClassType>> getInvertedTypeHierarchy(
- JClassType root) {
+ private static Map<JClassType, List<JClassType>> getInvertedTypeHierarchy(JClassType root) {
Map<JClassType, List<JClassType>> adjList = new HashMap<JClassType, List<JClassType>>();
Set<JClassType> seen = new HashSet<JClassType>();
Stack<JClassType> queue = new Stack<JClassType>();
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 e9d2874..219aaef 100644
--- a/user/src/com/google/gwt/user/rebind/rpc/TypeParameterExposureComputer.java
+++ b/user/src/com/google/gwt/user/rebind/rpc/TypeParameterExposureComputer.java
@@ -1,12 +1,12 @@
/*
* Copyright 2008 Google Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -53,11 +53,13 @@
* dimensionality should be added to the dimensionality that the key is
* already exposed as.
*/
- private final Map<TypeParameterFlowInfo, Integer> causesExposure = new LinkedHashMap<TypeParameterFlowInfo, Integer>();
+ private final Map<TypeParameterFlowInfo, Integer> causesExposure =
+ new LinkedHashMap<TypeParameterFlowInfo, Integer>();
private int exposure = EXPOSURE_NONE;
- private final Map<TypeParameterFlowInfo, Boolean> isTransitivelyAffectedByCache = new HashMap<TypeParameterFlowInfo, Boolean>();
+ private final Map<TypeParameterFlowInfo, Boolean> isTransitivelyAffectedByCache =
+ new HashMap<TypeParameterFlowInfo, Boolean>();
/**
* Type parameters that need to be notified when my exposure changes.
@@ -84,12 +86,12 @@
while (type != null) {
// any problems should already have been captured by our caller, so we
// make a throw-away ProblemReport here.
- if (SerializableTypeOracleBuilder.shouldConsiderFieldsForSerialization(
- type, typeFilter, new ProblemReport())) {
+ if (SerializableTypeOracleBuilder.shouldConsiderFieldsForSerialization(type, typeFilter,
+ new ProblemReport())) {
JField[] fields = type.getFields();
for (JField field : fields) {
- if (!SerializableTypeOracleBuilder.shouldConsiderForSerialization(
- TreeLogger.NULL, true, field)) {
+ if (!SerializableTypeOracleBuilder.shouldConsiderForSerialization(TreeLogger.NULL,
+ true, field)) {
continue;
}
@@ -172,8 +174,7 @@
int dimensionDelta = entry.getValue();
if (info2.getExposure() >= 0) {
if (!infiniteArrayExpansionPathBetween(info2)) {
- didChange |= markExposedAsArray(dimensionDelta
- + info2.getExposure());
+ didChange |= markExposedAsArray(dimensionDelta + info2.getExposure());
}
}
}
@@ -253,8 +254,8 @@
// any problems should already have been captured by our caller, so we
// make a throw-away ProblemReport here.
- if (!SerializableTypeOracleBuilder.shouldConsiderFieldsForSerialization(
- subtype, typeFilter, new ProblemReport())) {
+ if (!SerializableTypeOracleBuilder.shouldConsiderFieldsForSerialization(subtype,
+ typeFilter, new ProblemReport())) {
continue;
}
@@ -270,12 +271,12 @@
JClassType type = baseType;
while (type != null) {
- if (SerializableTypeOracleBuilder.shouldConsiderFieldsForSerialization(
- type, typeFilter, new ProblemReport())) {
+ if (SerializableTypeOracleBuilder.shouldConsiderFieldsForSerialization(type, typeFilter,
+ new ProblemReport())) {
JField[] fields = type.getFields();
for (JField field : fields) {
- if (!SerializableTypeOracleBuilder.shouldConsiderForSerialization(
- TreeLogger.NULL, true, field)) {
+ if (!SerializableTypeOracleBuilder.shouldConsiderForSerialization(TreeLogger.NULL,
+ true, field)) {
continue;
}
@@ -290,8 +291,7 @@
JGenericType genericFieldType = isParameterized.getBaseType();
recordCausesExposure(genericFieldType, i, 0);
JArrayType typeArgIsArray = typeArgs[i].isArray();
- if (typeArgIsArray != null
- && typeArgIsArray.getLeafType() == getTypeParameter()) {
+ if (typeArgIsArray != null && typeArgIsArray.getLeafType() == getTypeParameter()) {
int dims = typeArgIsArray.getRank();
recordCausesExposure(genericFieldType, i, dims);
}
@@ -318,8 +318,7 @@
* returned flow info.
*/
private TypeParameterFlowInfo getFlowInfo(JGenericType type, int index) {
- TypeParameterFlowInfo flowInfo = TypeParameterExposureComputer.this.getFlowInfo(
- type, index);
+ TypeParameterFlowInfo flowInfo = TypeParameterExposureComputer.this.getFlowInfo(type, index);
flowInfo.addListener(this);
return flowInfo;
}
@@ -333,11 +332,9 @@
}
}
- private boolean referencesTypeParameter(JClassType classType,
- JTypeParameter typeParameter) {
+ private boolean referencesTypeParameter(JClassType classType, JTypeParameter typeParameter) {
Set<JTypeParameter> typeParameters = new LinkedHashSet<JTypeParameter>();
- SerializableTypeOracleBuilder.recordTypeParametersIn(classType,
- typeParameters);
+ SerializableTypeOracleBuilder.recordTypeParametersIn(classType, typeParameters);
return typeParameters.contains(typeParameter);
}
}
@@ -360,7 +357,8 @@
private TypeFilter typeFilter;
- private final Map<JTypeParameter, TypeParameterFlowInfo> typeParameterToFlowInfo = new IdentityHashMap<JTypeParameter, TypeParameterFlowInfo>();
+ private final Map<JTypeParameter, TypeParameterFlowInfo> typeParameterToFlowInfo =
+ new IdentityHashMap<JTypeParameter, TypeParameterFlowInfo>();
private final Set<TypeParameterFlowInfo> worklist = new LinkedHashSet<TypeParameterFlowInfo>();
@@ -371,12 +369,11 @@
/**
* Computes flow information for the specified type parameter. If it has
* already been computed just return the value of the previous computation.
- *
+ *
* @param type the generic type whose type parameter flow we are interested in
* @param index the index of the type parameter whose flow we want to compute
*/
- public TypeParameterFlowInfo computeTypeParameterExposure(JGenericType type,
- int index) {
+ public TypeParameterFlowInfo computeTypeParameterExposure(JGenericType type, int index) {
// check if it has already been computed
JTypeParameter[] typeParameters = type.getTypeParameters();
assert (index < typeParameters.length);
diff --git a/user/src/com/google/gwt/user/rebind/rpc/TypePaths.java b/user/src/com/google/gwt/user/rebind/rpc/TypePaths.java
index ede05da..643e929 100644
--- a/user/src/com/google/gwt/user/rebind/rpc/TypePaths.java
+++ b/user/src/com/google/gwt/user/rebind/rpc/TypePaths.java
@@ -34,16 +34,16 @@
*/
interface TypePath {
/**
- * Get the previous element on this type path, or <code>null</code> if
- * this is a one-element path.
+ * Get the previous element on this type path, or <code>null</code> if this
+ * is a one-element path.
*/
TypePath getParent();
String toString();
}
- static TypePaths.TypePath createArrayComponentPath(
- final JArrayType arrayType, final TypePaths.TypePath parent) {
+ static TypePaths.TypePath createArrayComponentPath(final JArrayType arrayType,
+ final TypePaths.TypePath parent) {
assert (arrayType != null);
return new TypePaths.TypePath() {
@@ -53,16 +53,14 @@
@Override
public String toString() {
- return "Type '"
- + arrayType.getComponentType().getParameterizedQualifiedSourceName()
- + "' is reachable from array type '"
- + arrayType.getParameterizedQualifiedSourceName() + "'";
+ return "Type '" + arrayType.getComponentType().getParameterizedQualifiedSourceName()
+ + "' is reachable from array type '" + arrayType.getParameterizedQualifiedSourceName()
+ + "'";
}
};
}
- static TypePaths.TypePath createFieldPath(final TypePaths.TypePath parent,
- final JField field) {
+ static TypePaths.TypePath createFieldPath(final TypePaths.TypePath parent, final JField field) {
return new TypePaths.TypePath() {
public TypePaths.TypePath getParent() {
return parent;
@@ -72,9 +70,9 @@
public String toString() {
JType type = field.getType();
JClassType enclosingType = field.getEnclosingType();
- return "'" + type.getParameterizedQualifiedSourceName()
- + "' is reachable from field '" + field.getName() + "' of type '"
- + enclosingType.getParameterizedQualifiedSourceName() + "'";
+ return "'" + type.getParameterizedQualifiedSourceName() + "' is reachable from field '"
+ + field.getName() + "' of type '" + enclosingType.getParameterizedQualifiedSourceName()
+ + "'";
}
};
}
@@ -89,14 +87,13 @@
@Override
public String toString() {
- return "Started from '" + type.getParameterizedQualifiedSourceName()
- + "'";
+ return "Started from '" + type.getParameterizedQualifiedSourceName() + "'";
}
};
}
- static TypePaths.TypePath createSubtypePath(final TypePaths.TypePath parent,
- final JType type, final JClassType supertype) {
+ static TypePaths.TypePath createSubtypePath(final TypePaths.TypePath parent, final JType type,
+ final JClassType supertype) {
assert (type != null);
assert (supertype != null);
@@ -113,8 +110,7 @@
};
}
- static TypePaths.TypePath createSupertypePath(
- final TypePaths.TypePath parent, final JType type,
+ static TypePaths.TypePath createSupertypePath(final TypePaths.TypePath parent, final JType type,
final JClassType subtype) {
assert (type != null);
assert (subtype != null);
@@ -132,9 +128,8 @@
};
}
- static TypePaths.TypePath createTypeArgumentPath(
- final TypePaths.TypePath parent, final JGenericType baseType,
- final int typeArgIndex, final JClassType typeArg) {
+ static TypePaths.TypePath createTypeArgumentPath(final TypePaths.TypePath parent,
+ final JGenericType baseType, final int typeArgIndex, final JClassType typeArg) {
assert (baseType != null);
assert (typeArg != null);
@@ -146,15 +141,14 @@
@Override
public String toString() {
return "'" + typeArg.getParameterizedQualifiedSourceName()
- + "' is reachable from type argument " + typeArgIndex
- + " of type '" + baseType.getParameterizedQualifiedSourceName()
- + "'";
+ + "' is reachable from type argument " + typeArgIndex + " of type '"
+ + baseType.getParameterizedQualifiedSourceName() + "'";
}
};
}
- static TypePaths.TypePath createTypeParameterInRootPath(
- final TypePaths.TypePath parent, final JTypeParameter typeParameter) {
+ static TypePaths.TypePath createTypeParameterInRootPath(final TypePaths.TypePath parent,
+ final JTypeParameter typeParameter) {
assert (typeParameter != null);
return new TypePaths.TypePath() {
@@ -166,13 +160,12 @@
public String toString() {
String parameterString = typeParameter.getName();
if (typeParameter.getDeclaringClass() != null) {
- parameterString += " of class "
- + typeParameter.getDeclaringClass().getQualifiedSourceName();
+ parameterString +=
+ " of class " + typeParameter.getDeclaringClass().getQualifiedSourceName();
}
- return "'"
- + typeParameter.getFirstBound().getParameterizedQualifiedSourceName()
- + "' is reachable as an upper bound of type parameter "
- + parameterString + ", which appears in a root type";
+ return "'" + typeParameter.getFirstBound().getParameterizedQualifiedSourceName()
+ + "' is reachable as an upper bound of type parameter " + parameterString
+ + ", which appears in a root type";
}
};
}
diff --git a/user/src/com/google/gwt/user/rebind/rpc/TypeSerializerCreator.java b/user/src/com/google/gwt/user/rebind/rpc/TypeSerializerCreator.java
index 98c2734..436d1c6 100644
--- a/user/src/com/google/gwt/user/rebind/rpc/TypeSerializerCreator.java
+++ b/user/src/com/google/gwt/user/rebind/rpc/TypeSerializerCreator.java
@@ -82,20 +82,19 @@
private static int shardSize = -1;
- private static void computeShardSize(TreeLogger logger)
- throws UnableToCompleteException {
- String shardSizeProperty = System.getProperty(
- GWT_CREATEMETHODMAP_SHARD_SIZE, DEFAULT_CREATEMETHODMAP_SHARD_SIZE);
+ private static void computeShardSize(TreeLogger logger) throws UnableToCompleteException {
+ String shardSizeProperty =
+ System.getProperty(GWT_CREATEMETHODMAP_SHARD_SIZE, DEFAULT_CREATEMETHODMAP_SHARD_SIZE);
try {
shardSize = Integer.valueOf(shardSizeProperty);
if (shardSize < 0) {
- logger.log(TreeLogger.ERROR, GWT_CREATEMETHODMAP_SHARD_SIZE
- + " must be non-negative: " + shardSizeProperty);
+ logger.log(TreeLogger.ERROR, GWT_CREATEMETHODMAP_SHARD_SIZE + " must be non-negative: "
+ + shardSizeProperty);
throw new UnableToCompleteException();
}
} catch (NumberFormatException e) {
- logger.log(TreeLogger.ERROR, "Property " + GWT_CREATEMETHODMAP_SHARD_SIZE
- + " not a number: " + shardSizeProperty, e);
+ logger.log(TreeLogger.ERROR, "Property " + GWT_CREATEMETHODMAP_SHARD_SIZE + " not a number: "
+ + shardSizeProperty, e);
throw new UnableToCompleteException();
}
}
@@ -120,8 +119,7 @@
private final Map<JType, String> typeStrings = new IdentityHashMap<JType, String>();
- public TypeSerializerCreator(TreeLogger logger,
- SerializableTypeOracle serializationOracle,
+ public TypeSerializerCreator(TreeLogger logger, SerializableTypeOracle serializationOracle,
SerializableTypeOracle deserializationOracle, GeneratorContextExt context,
String typeSerializerClassName, String typeSerializerSimpleName)
throws UnableToCompleteException {
@@ -137,8 +135,7 @@
typesSet.addAll(Arrays.asList(serializationOracle.getSerializableTypes()));
typesSet.addAll(Arrays.asList(deserializationOracle.getSerializableTypes()));
serializableTypes = typesSet.toArray(new JType[0]);
- Arrays.sort(serializableTypes,
- SerializableTypeOracleBuilder.JTYPE_COMPARATOR);
+ Arrays.sort(serializableTypes, SerializableTypeOracleBuilder.JTYPE_COMPARATOR);
srcWriter = getSourceWriter(logger, context);
if (shardSize < 0) {
@@ -150,13 +147,11 @@
}
try {
- ConfigurationProperty prop
- = context.getPropertyOracle().getConfigurationProperty(
- GWT_ELIDE_TYPE_NAMES_FROM_RPC);
+ ConfigurationProperty prop =
+ context.getPropertyOracle().getConfigurationProperty(GWT_ELIDE_TYPE_NAMES_FROM_RPC);
elideTypeNames = Boolean.parseBoolean(prop.getValues().get(0));
} catch (BadPropertyValueException e) {
- logger.log(TreeLogger.ERROR, "The configuration property "
- + GWT_ELIDE_TYPE_NAMES_FROM_RPC
+ logger.log(TreeLogger.ERROR, "The configuration property " + GWT_ELIDE_TYPE_NAMES_FROM_RPC
+ " was not defined. Is RemoteService.gwt.xml inherited?");
throw new UnableToCompleteException();
}
@@ -167,8 +162,8 @@
}
public String realize(TreeLogger logger) {
- logger = logger.branch(TreeLogger.DEBUG,
- "Generating TypeSerializer for service interface '"
+ logger =
+ logger.branch(TreeLogger.DEBUG, "Generating TypeSerializer for service interface '"
+ typeSerializerClassName + "'", null);
createFieldSerializers(logger, context);
@@ -203,42 +198,42 @@
return typeSerializerClassName;
}
-
+
/*
* Create a field serializer for a type if it does not have a custom
* serializer.
*/
- private void createFieldSerializer(TreeLogger logger, GeneratorContextExt ctx,
- JType type) {
+ private void createFieldSerializer(TreeLogger logger, GeneratorContextExt ctx, JType type) {
Event event = SpeedTracerLogger.start(CompilerEventType.GENERATOR_RPC_FIELD_SERIALIZER);
try {
assert (type != null);
- assert (serializationOracle.isSerializable(type) || deserializationOracle.isSerializable(type));
-
+ assert (serializationOracle.isSerializable(type) || deserializationOracle
+ .isSerializable(type));
+
JParameterizedType parameterizedType = type.isParameterized();
if (parameterizedType != null) {
createFieldSerializer(logger, ctx, parameterizedType.getRawType());
return;
}
-
+
/*
- * Only a JClassType can reach this point in the code. JPrimitives have been
- * removed because their serialization is built in, interfaces have been
- * removed because they are not an instantiable type and parameterized types
- * have been broken down into their raw types.
+ * Only a JClassType can reach this point in the code. JPrimitives have
+ * been removed because their serialization is built in, interfaces have
+ * been removed because they are not an instantiable type and
+ * parameterized types have been broken down into their raw types.
*/
assert (type.isClass() != null || type.isArray() != null);
-
+
if (findCacheableFieldSerializerAndMarkForReuseIfAvailable(ctx, type)) {
// skip generation of field serializer
return;
}
-
- JClassType customFieldSerializer = SerializableTypeOracleBuilder.findCustomFieldSerializer(
- typeOracle, type);
- FieldSerializerCreator creator = new FieldSerializerCreator(context,
- serializationOracle, deserializationOracle, (JClassType) type,
- customFieldSerializer);
+
+ JClassType customFieldSerializer =
+ SerializableTypeOracleBuilder.findCustomFieldSerializer(typeOracle, type);
+ FieldSerializerCreator creator =
+ new FieldSerializerCreator(context, serializationOracle, deserializationOracle,
+ (JClassType) type, customFieldSerializer);
creator.realize(logger, ctx);
} finally {
event.end();
@@ -258,23 +253,22 @@
createFieldSerializer(logger, ctx, type);
}
}
-
+
/*
- * check whether we can use a previously generated version of a
- * FieldSerializer. If so, mark it for reuse, and return true.
- * Otherwise return false.
+ * check whether we can use a previously generated version of a
+ * FieldSerializer. If so, mark it for reuse, and return true. Otherwise
+ * return false.
*/
- private boolean findCacheableFieldSerializerAndMarkForReuseIfAvailable(
- GeneratorContextExt ctx, JType type) {
-
+ private boolean findCacheableFieldSerializerAndMarkForReuseIfAvailable(GeneratorContextExt ctx,
+ JType type) {
+
CachedRebindResult lastResult = ctx.getCachedGeneratorResult();
if (lastResult == null || !ctx.isGeneratorResultCachingEnabled()) {
return false;
}
-
- String fieldSerializerName =
- SerializationUtils.getStandardSerializerName((JClassType) type);
-
+
+ String fieldSerializerName = SerializationUtils.getStandardSerializerName((JClassType) type);
+
if (type instanceof JClassType) {
// check that it is available for reuse
if (!lastResult.isTypeCached(fieldSerializerName)) {
@@ -283,26 +277,26 @@
} else {
return false;
}
-
+
try {
/*
- * TODO(jbrosenberg): Change this check to use getVersion() from
+ * TODO(jbrosenberg): Change this check to use getVersion() from
* TypeOracle, once that is available.
*/
long lastModified = ctx.getSourceLastModifiedTime((JClassType) type);
-
- if (lastModified != 0L &&
- lastModified < lastResult.getTimeGenerated()) {
-
- // use cached version
+
+ if (lastModified != 0L && lastModified < lastResult.getTimeGenerated()) {
+
+ // use cached version
return ctx.reuseTypeFromCacheIfAvailable(fieldSerializerName);
}
} catch (RuntimeException ex) {
// could get an exception checking modified time
}
-
+
return false;
}
+
private String[] getPackageAndClassName(String fullClassName) {
String className = fullClassName;
String packageName = "";
@@ -327,8 +321,8 @@
return null;
}
- ClassSourceFileComposerFactory composerFactory = new ClassSourceFileComposerFactory(
- packageName, className);
+ ClassSourceFileComposerFactory composerFactory =
+ new ClassSourceFileComposerFactory(packageName, className);
composerFactory.addImport(GWT.class.getName());
composerFactory.addImport(JsArrayString.class.getName());
@@ -346,8 +340,9 @@
* @return
*/
private String getTypeString(JType type) {
- String typeString = SerializationUtils.getRpcTypeName(type) + "/"
- + SerializationUtils.getSerializationSignature(typeOracle, type);
+ String typeString =
+ SerializationUtils.getRpcTypeName(type) + "/"
+ + SerializationUtils.getSerializationSignature(typeOracle, type);
return typeString;
}
@@ -356,8 +351,8 @@
* method.
*/
private boolean hasInstantiateMethod(JClassType customSerializer, JType type) {
- return CustomFieldSerializerValidator.getInstantiationMethod(
- customSerializer, (JClassType) type) != null;
+ return CustomFieldSerializerValidator.getInstantiationMethod(customSerializer,
+ (JClassType) type) != null;
}
/**
@@ -374,14 +369,14 @@
if (context.isProdMode()) {
srcWriter.indentln("super(null, methodMapNative, null, signatureMapNative);");
} else {
- srcWriter.indentln("super(methodMapJava, null, signatureMapJava, null);");
+ srcWriter.indentln("super(methodMapJava, null, signatureMapJava, null);");
}
srcWriter.println("}");
srcWriter.println();
}
/**
- * Writes a method to produce a map of type string -> class name of
+ * Writes a method to produce a map of type string -> class name of
* {@link TypeHandler} for Java.
*
* <pre>
@@ -414,11 +409,9 @@
for (JType type : filteredTypes) {
String typeString = typeStrings.get(type);
- assert typeString != null : "Missing type signature for "
- + type.getQualifiedSourceName();
+ assert typeString != null : "Missing type signature for " + type.getQualifiedSourceName();
srcWriter.println("result.put(\"" + typeString + "\", \""
- + SerializationUtils.getStandardSerializerName((JClassType) type)
- + "\");");
+ + SerializationUtils.getStandardSerializerName((JClassType) type) + "\");");
}
srcWriter.println("return result;");
@@ -475,8 +468,7 @@
}
String typeString = typeStrings.get(type);
- assert typeString != null : "Missing type signature for "
- + type.getQualifiedSourceName();
+ assert typeString != null : "Missing type signature for " + type.getQualifiedSourceName();
srcWriter.println("result[\"" + typeString + "\"] = [");
srcWriter.indent();
@@ -526,8 +518,8 @@
}
String typeRef;
- JClassType customSerializer = SerializableTypeOracleBuilder.findCustomFieldSerializer(
- typeOracle, type);
+ JClassType customSerializer =
+ SerializableTypeOracleBuilder.findCustomFieldSerializer(typeOracle, type);
if (customSerializer != null
&& CustomFieldSerializerValidator.getConcreteTypeMethod(customSerializer) != null) {
typeRef = customSerializer.getQualifiedSourceName() + ".concreteType()";
@@ -558,7 +550,7 @@
*/
private void writeLoadSignaturesNative() {
srcWriter.println("@SuppressWarnings(\"deprecation\")");
- srcWriter.println("@GwtScriptOnly");
+ srcWriter.println("@GwtScriptOnly");
srcWriter.println("private static native JsArrayString loadSignaturesNative() /*-{");
srcWriter.indent();
srcWriter.println("var result = [];");
@@ -583,8 +575,9 @@
srcWriter.println("(function() {");
}
- srcWriter.println("result[@com.google.gwt.core.client.impl.Impl::getHashCode(Ljava/lang/Object;)(@"
- + type.getQualifiedSourceName() + "::class)] = \"" + typeString + "\";");
+ srcWriter
+ .println("result[@com.google.gwt.core.client.impl.Impl::getHashCode(Ljava/lang/Object;)(@"
+ + type.getQualifiedSourceName() + "::class)] = \"" + typeString + "\";");
}
if (shard) {
@@ -613,7 +606,7 @@
srcWriter.println("private static final JsArrayString signatureMapNative;");
} else {
srcWriter.println("private static final Map<String, String> methodMapJava;");
- srcWriter.println("private static final Map<String, String> signatureMapJava;");
+ srcWriter.println("private static final Map<String, String> signatureMapJava;");
}
srcWriter.println();
}
@@ -659,10 +652,9 @@
*/
private void writeTypeMethodsNative(JType type) {
srcWriter.indent();
- String serializerName = SerializationUtils.getFieldSerializerName(
- typeOracle, type);
- JClassType customSerializer = SerializableTypeOracleBuilder.findCustomFieldSerializer(
- typeOracle, type);
+ String serializerName = SerializationUtils.getFieldSerializerName(typeOracle, type);
+ JClassType customSerializer =
+ SerializableTypeOracleBuilder.findCustomFieldSerializer(typeOracle, type);
// First the initialization method
if (deserializationOracle.maybeInstantiated(type)) {
@@ -677,8 +669,7 @@
srcWriter.print(serializerName);
}
srcWriter.print("::instantiate");
- srcWriter.print("(L"
- + SerializationStreamReader.class.getName().replace('.', '/') + ";)");
+ srcWriter.print("(L" + SerializationStreamReader.class.getName().replace('.', '/') + ";)");
}
srcWriter.println(",");
@@ -688,8 +679,9 @@
JType paramType = type;
if (customSerializer != null) {
// But a custom serializer may specify a looser type.
- JMethod deserializationMethod = CustomFieldSerializerValidator.getDeserializationMethod(
- customSerializer, (JClassType) type);
+ JMethod deserializationMethod =
+ CustomFieldSerializerValidator.getDeserializationMethod(customSerializer,
+ (JClassType) type);
paramType = deserializationMethod.getParameters()[1].getType();
}
srcWriter.print("@" + serializerName);
@@ -705,14 +697,14 @@
JType paramType = type;
if (customSerializer != null) {
// But a custom serializer may specify a looser type.
- JMethod serializationMethod = CustomFieldSerializerValidator.getSerializationMethod(
- customSerializer, (JClassType) type);
+ JMethod serializationMethod =
+ CustomFieldSerializerValidator.getSerializationMethod(customSerializer,
+ (JClassType) type);
paramType = serializationMethod.getParameters()[1].getType();
}
srcWriter.print("@" + serializerName);
- srcWriter.print("::serialize(L"
- + SerializationStreamWriter.class.getName().replace('.', '/') + ";"
- + paramType.getJNISignature() + ")");
+ srcWriter.print("::serialize(L" + SerializationStreamWriter.class.getName().replace('.', '/')
+ + ";" + paramType.getJNISignature() + ")");
srcWriter.println();
}
srcWriter.outdent();