tags:

views:

112

answers:

2

I am having trouble using EnumSet on the client side.

I get this runtime error message:

java.util.EnumSet.EnumSetImpl is not default instantiable (it must have a zero-argument constructor or no constructors at all) and has no custom serializer.

Is this is a known issue?

Here is what I am doing (basically a hello world app)

Service:

String echo (EnumSet<Names> name) throws IllegalArgumentException;

Client:

echoServ.echo (EnumSet.of(Names.JOHN), new AsyncCallback<String>()
{ ....... });

Shared enum class enum Names { JOHN, NUMAN, OBAMA }

A: 

It seems the problem is that EnumSet is not serializable according to GWT's rules:

  1. It is assignable to IsSerializable or Serializable, either because it directly implements one of these interfaces or because it derives from a superclass that does
  2. All non-final, non-transient instance fields are themselves serializable, and
  3. As of GWT 1.5, it must have a default (zero argument) constructor (with any access modifier) or no constructor at all.

See the docs for more info.

Igor Klimer
+2  A: 

This is a GWT limitation - See http://code.google.com/p/google-web-toolkit/issues/detail?id=3028

The simplest workaround is to use a HashSet until that is fixed

Chi