Java.util.LinkedList.Node <E> cannot be assigned GWT Serializable?
I get a lot of errors when I try to compile my GWT application. Some of them
[ERROR] com.google.gwt.xml.client.impl.AttrImpl is not default instantiable (it must have a zero-argument constructor or no constructors at all) and has no custom serializer. [ERROR] com.google.gwt.xml.client.impl.CDATASectionImpl is not default instantiable (it must have a zero-argument constructor or no constructors at all) and has no custom serializer. [ERROR] com.google.gwt.xml.client.impl.CommentImpl is not default instantiable (it must have a zero-argument constructor or no constructors at all) and has no custom serializer. [ERROR] com.google.gwt.xml.client.impl.DocumentFragmentImpl is not default instantiable (it must have a zero-argument constructor or no constructors at all) and has no custom serializer. [ERROR] com.google.gwt.xml.client.impl.DocumentImpl is not default instantiable (it must have a zero-argument constructor or no constructors at all) and has no custom serializer. [ERROR] com.google.gwt.xml.client.impl.ElementImpl is not default instantiable (it must have a zero-argument constructor or no constructors at all) and has no custom serializer. [ERROR] com.google.gwt.xml.client.impl.EntityReferenceImpl is not default instantiable (it must have a zero-argument constructor or no constructors at all) and has no custom serializer. [ERROR] com.google.gwt.xml.client.impl.NamedNodeMapImpl is not default instantiable (it must have a zero-argument constructor or no constructors at all) and has no custom serializer. [ERROR] com.google.gwt.xml.client.impl.NodeImpl is not default instantiable (it must have a zero-argument constructor or no constructors at all) and has no custom serializer. [ERROR] com.google.gwt.xml.client.impl.NodeListImpl is not default instantiable (it must have a zero-argument constructor or no constructors at all) and has no custom serializer. [ERROR] com.google.gwt.xml.client.impl.ProcessingInstructionImpl is not default instantiable (it must have a zero-argument constructor or no constructors at all) and has no custom serializer. [ERROR] com.google.gwt.xml.client.impl.TextImpl is not default instantiable (it must have a zero-argument constructor or no constructors at all) and has no custom serializer. [ERROR] java.util.AbstractList.SubList<E> is not default instantiable (it must have a zero-argument constructor or no constructors at all) and has no custom serializer. [ERROR] java.util.AbstractList.SubList<E> is not default instantiable (it must have a zero-argument constructor or no constructors at all) and has no custom serializer. [ERROR] java.util.Collections.UnmodifiableList<T> is not default instantiable (it must have a zero-argument constructor or no constructors at all) and has no custom serializer. [ERROR] java.util.Collections.UnmodifiableList<T> is not default instantiable (it must have a zero-argument constructor or no constructors at all) and has no custom serializer. [ERROR] java.util.Collections.UnmodifiableRandomAccessList<T> is not default instantiable (it must have a zero-argument constructor or no constructors at all) and has no custom serializer. [ERROR] java.util.Collections.UnmodifiableRandomAccessList<T> is not default instantiable (it must have a zero-argument constructor or no constructors at all) and has no custom serializer. [ERROR] java.util.LinkedList.Node<E> is not assignable to 'com.google.gwt.user.client.rpc.IsSerializable' or 'java.io.Serializable' nor does it have a custom field serializer [ERROR] java.util.LinkedList.Node<E> has no available instantiable subtypes. [ERROR] subtype java.util.LinkedList.Node<E> is not assignable to 'com.google.gwt.user.client.rpc.IsSerializable' or 'java.io.Serializable' nor does it have a custom field serializer I get this error in my client code! From all that I could read from the Internet, he says that I simply cannot emulate all the standard methods that run in the JRE container in GWT, because it will be compiled into Javascript at runtime. But I'm too inexperienced to understand this mistake. Thank any help in this regard!
Three maxims:
- GWT Java is Java, but not Java
- GWT Java is a Java Javascript compiler.
- Serializable Deployment Cannot Be GWT Serializable
Could it be serialized if it implements Serializable?
In the java SE / EE bytecode world, serialization is easier. In the following class declaration:
class Spider implements Serializable{ String a; Integer b; Cobweb c; } The compiler will move around a and b because String already has its own serialization encoder (i.e. encoder / decoder or marshaller / unmarshaller). Also Integer.
The compiler then tries to find out if Cobweb implements Serializable either by providing its own codec, or if Cobweb contains Serializable members, such as
class Cobweb implements Serializable{ Boolean d; Double e; } Both d and e already have a serialization codec, provided by the courtesy of the Sun / Oracle Java language guide.
What if CobWeb allows for common arguments?
class Cobweb <T> implements Serializable{ Boolean d; T e; } Cobweb<Float> will be serialized because Java already has a serialization codec for Float.
However, if Donkey does not have a special serialization codec, the compiler will crunch as follows
class Spider implements Serializable{ String a; Integer b; Cobweb<Donkey> c; } What does the GWT serializer mean?
Doesn't implement Serializable enough? Why is Google introducing a new Serializable interface? Nope. This is a Google bug, but not a Google bug.
The GWT Java user interface is always compiled in Javascript prior to its launch. The native code for GWT UI Java is Javascript, not binary Java bytecode. For a simple and obvious reason, the browser uses only Javascript, but not Java bytecode.
In most cases, implementing Serializable will make your serializable GWT class. Being serializable by GWT means that there is a GWT Javascript code that exists to execute the codec when necessary. that is, the codec is in the Java source, and not in the Java byte code. The codec must be translatable into Javascript because GWT serialization / deserialization is done in the browser.
However, there are many classes that GWT no longer has a codec. For example, GregorianCalender and most classes that require Reflection. GregorianCalender implements Serializable, but the GWT compiler does not have a codec for it in the Java source code, which can be converted to Javascript.
GWT-generated Javascript is not able to reflect runtime. In this way, GWT compensates for this shortcoming by delaying the binding of precompiled permutations of all the possible code that you could use. I believe that GregorianCalendar does some Reflection and writing a GWT codec for GregorianCalendar will be too many permutations of Javascript code. I believe this is the reason, as well as the reason for the lack of codec for many classes. Someone please correct me.
Return to the original question ....
java.util.LinkedList.Node<E> So, for God's sake, what is E in the world? Have you replaced E with serializable GWT?
The data from the stack trace (even if I'm good at tracking the stack trace) indicates that you did not even bother to replace the general argument with the actual type. By doing this, you force the GWT compiler to treat E as an object of the class. And no one knows how to serialize a class object. You will be like the pharaoh in Genesis 41 telling Joseph
"Joseph, please interpret my dream, but I forgot my dream, so you should tell me about my dream too."
As the first line of the stack says, for serialization, the class must have a constructor without parameters or its own custom serializer. java-custom-serialization there is a topic about writing serializer