GWT

Emulate JRE classes

  • Add a super-source entry in the module xml file. For example <super-source path="jre"/>
  • Create a emulator file under the super source path. For example, to emulate java.util.UUID class, create the file ..../jre/java/util/UUID.java
    • Put that file under the resources folder, not the src folder because we don't want java compilers to compile that file, only GWT compiler compiles it.
    • Implement all public methods of that class
  • Create a CustomFieldSerializer for that type.
    • GWT convention: if type a.b.c.TypeXyz, the serializer must be a.b.c.TypeXyz_CustomFieldSerializer
    • But we can't create same package as JRE. GWT has a magic package for this purpose: com.google.gwt.user.client.rpc.core So, create a com.google.gwt.user.client.rpc.core.java.util.UUID_CustomFieldSerializer there.

Errors in ...com/google/gwt/emul/java/lang/... No source code is available for ...

To solve, delete all gwt-unitCache-* files in the gwt-unitCache folder, for example <web module>/src/main/gwt-unitCache