summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2012-04-20 11:49:27 +0300
committerArtur Signell <artur@vaadin.com>2012-04-20 11:49:27 +0300
commit1bfd63b2b701232e6ade5d0c96ee91e25fd07cce (patch)
tree9b742fdefcb42c5da7ad256b8200237b06651705
parentfe192de4cad75d6bf8141dd0c09e1a333198ef6d (diff)
downloadvaadin-framework-7.0.0.alpha2.tar.gz
vaadin-framework-7.0.0.alpha2.zip
Added test to ensure shared classes are Serializable (#8710)7.0.0.alpha2
Corrected SplitterState to be Serializable.
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/splitpanel/AbstractSplitPanelState.java4
-rw-r--r--src/com/vaadin/terminal/gwt/widgetsetutils/SerializerMapGenerator.java34
2 files changed, 36 insertions, 2 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/splitpanel/AbstractSplitPanelState.java b/src/com/vaadin/terminal/gwt/client/ui/splitpanel/AbstractSplitPanelState.java
index 13f3adbc72..8b80eed840 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/splitpanel/AbstractSplitPanelState.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/splitpanel/AbstractSplitPanelState.java
@@ -3,6 +3,8 @@
*/
package com.vaadin.terminal.gwt.client.ui.splitpanel;
+import java.io.Serializable;
+
import com.vaadin.terminal.gwt.client.ComponentState;
import com.vaadin.terminal.gwt.client.Connector;
@@ -44,7 +46,7 @@ public class AbstractSplitPanelState extends ComponentState {
this.splitterState = splitterState;
}
- public static class SplitterState {
+ public static class SplitterState implements Serializable {
private float position;
private String positionUnit;
private boolean positionReversed = false;
diff --git a/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerMapGenerator.java b/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerMapGenerator.java
index e09545962b..013df4710c 100644
--- a/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerMapGenerator.java
+++ b/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerMapGenerator.java
@@ -5,6 +5,7 @@
package com.vaadin.terminal.gwt.widgetsetutils;
import java.io.PrintWriter;
+import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
@@ -52,6 +53,8 @@ public class SerializerMapGenerator extends Generator {
TypeOracle typeOracle = context.getTypeOracle();
Set<JClassType> typesNeedingSerializers = findTypesNeedingSerializers(
typeOracle, logger);
+ warnIfNotJavaSerializable(typesNeedingSerializers, typeOracle,
+ logger);
Set<JClassType> typesWithExistingSerializers = findTypesWithExistingSerializers(
typeOracle, logger);
Set<JClassType> serializerMappings = new HashSet<JClassType>();
@@ -77,6 +80,34 @@ public class SerializerMapGenerator extends Generator {
return packageName + "." + className;
}
+ /**
+ * Emits a warning for all classes that are used in communication but do not
+ * implement java.io.Serializable. Implementing java.io.Serializable is not
+ * needed for communication but for the server side Application to be
+ * serializable i.e. work in GAE for instance.
+ *
+ * @param typesNeedingSerializers
+ * @param typeOracle
+ * @param logger
+ */
+ private void warnIfNotJavaSerializable(
+ Set<JClassType> typesNeedingSerializers, TypeOracle typeOracle,
+ TreeLogger logger) {
+ JClassType javaSerializable = typeOracle.findType(Serializable.class
+ .getName());
+ for (JClassType type : typesNeedingSerializers) {
+ boolean serializable = type.isAssignableTo(javaSerializable);
+ if (!serializable) {
+ logger.log(
+ Type.ERROR,
+ 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.");
+ }
+ }
+ }
+
private Set<JClassType> findTypesWithExistingSerializers(
TypeOracle typeOracle, TreeLogger logger) {
JClassType serializerInterface = typeOracle
@@ -233,8 +264,9 @@ public class SerializerMapGenerator extends Generator {
return;
}
- if (serializableTypes.contains(type))
+ if (serializableTypes.contains(type)) {
return;
+ }
JClassType typeClass = type.isClass();
if (typeClass != null) {