summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2012-07-25 11:17:36 +0300
committerLeif Åstrand <leif@vaadin.com>2012-07-25 11:17:36 +0300
commitdf98f12cb627c0272ab3fc4dd7175df5553118a3 (patch)
treed6709ca030b77a8a0131d69cf9204f49e5ce9002 /src
parentf21168aa4dde39f12a4f93d9e8f84c23d7f54418 (diff)
downloadvaadin-framework-df98f12cb627c0272ab3fc4dd7175df5553118a3.tar.gz
vaadin-framework-df98f12cb627c0272ab3fc4dd7175df5553118a3.zip
Fail build SerializerMapGenerator finds unserializable class (#8711)
This behavior is enabled by setting the system property vFailIfNotSerializable to true. The default is still to just log a warning but still continue compiling.
Diffstat (limited to 'src')
-rw-r--r--src/com/vaadin/terminal/gwt/widgetsetutils/SerializerMapGenerator.java20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerMapGenerator.java b/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerMapGenerator.java
index 2da2c85d8b..ab216693d7 100644
--- a/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerMapGenerator.java
+++ b/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerMapGenerator.java
@@ -43,6 +43,7 @@ import com.vaadin.terminal.gwt.client.communication.SharedState;
*/
public class SerializerMapGenerator extends Generator {
+ private static final String FAIL_IF_NOT_SERIALIZABLE = "vFailIfNotSerializable";
private String packageName;
private String className;
@@ -54,7 +55,7 @@ public class SerializerMapGenerator extends Generator {
TypeOracle typeOracle = context.getTypeOracle();
Set<JClassType> typesNeedingSerializers = findTypesNeedingSerializers(
typeOracle, logger);
- warnIfNotJavaSerializable(typesNeedingSerializers, typeOracle,
+ checkForUnserializableTypes(typesNeedingSerializers, typeOracle,
logger);
Set<JClassType> typesWithExistingSerializers = findTypesWithExistingSerializers(
typeOracle, logger);
@@ -90,10 +91,11 @@ public class SerializerMapGenerator extends Generator {
* @param typesNeedingSerializers
* @param typeOracle
* @param logger
+ * @throws UnableToCompleteException
*/
- private void warnIfNotJavaSerializable(
+ private void checkForUnserializableTypes(
Set<JClassType> typesNeedingSerializers, TypeOracle typeOracle,
- TreeLogger logger) {
+ TreeLogger logger) throws UnableToCompleteException {
JClassType javaSerializable = typeOracle.findType(Serializable.class
.getName());
for (JClassType type : typesNeedingSerializers) {
@@ -103,12 +105,20 @@ public class SerializerMapGenerator extends Generator {
}
boolean serializable = type.isAssignableTo(javaSerializable);
if (!serializable) {
+ boolean abortCompile = "true".equals(System
+ .getProperty(FAIL_IF_NOT_SERIALIZABLE));
logger.log(
- Type.ERROR,
+ abortCompile ? Type.ERROR : Type.WARN,
type
+ " is used in RPC or shared state but does not implement "
+ Serializable.class.getName()
- + ". Communication will work but the Application on server side cannot be serialized if it refers to objects of this type.");
+ + ". Communication will work but the Application on server side cannot be serialized if it refers to objects of this type. "
+ + "If the system property "
+ + FAIL_IF_NOT_SERIALIZABLE
+ + " is set to \"true\", this causes the compilation to fail instead of just emitting a warning.");
+ if (abortCompile) {
+ throw new UnableToCompleteException();
+ }
}
}
}