私はクラスをシリアル化しようとしています(文字通り3-4時間)。私は、既存の直列化可能と機能クラスにサブクラスを追加し、次のエラーメッセージを取得より:私は「プライベートLogCollection logColl」行をコメントするとGWT +シリアライズ
public class ItemRecRpc implements Serializable {
private static final long serialVersionUID = -5828108890651522661L;
.
.
private String rId;
private LogCollection logColl;//if i comment this, no error message...
public class LogCollection{
public LogCollection(){
}
//public long creationTime = System.currentTimeMillis();
//public LongVector times = new LongVector();
//public ArrayList<Object> messages = new ArrayList<Object>();
//public int nSkipped = 0;
//public int nExceptions = 0;
//public Exception firstException = null;
//public long endGcTime=0;
public long endTime;
}
.
.
.
}
:
[ERROR] com.google.gwt.user.client.ui.DelegatingChangeListenerCollection is not default instantiable (it must have a zero-argument constructor or no constructors at all) and has no custom serializer. (reached via com.client.rpc.ItemRecRpc)
[ERROR] com.google.gwt.user.client.ui.DelegatingClickListenerCollection is not default instantiable (it must have a zero-argument constructor or no constructors at all) and has no custom serializer. (reached via com.client.rpc.ItemRecRpc)
[ERROR] com.google.gwt.user.client.ui.DelegatingFocusListenerCollection is not default instantiable (it must have a zero-argument constructor or no constructors at all) and has no custom serializer. (reached via com.client.rpc.ItemRecRpc)
[ERROR] com.google.gwt.user.client.ui.DelegatingKeyboardListenerCollection is not default instantiable (it must have a zero-argument constructor or no constructors at all) and has no custom serializer. (reached via com.client.rpc.ItemRecRpc)
[ERROR] com.google.gwt.view.client.ListDataProvider<T>.ListWrapper<> is not default instantiable (it must have a zero-argument constructor or no constructors at all) and has no custom serializer. (reached via com.client.rpc.ItemRecRpc)
[ERROR] com.client.rpc.ItemRecRpc.LogCollection is not default instantiable (it must have a zero-argument constructor or no constructors at all) and has no custom serializer. (reached via com.client.rpc.ItemRecRpc)
[ERROR] com.client.rpc.ItemRecRpc.LogCollection has no available instantiable subtypes. (reached via com.client.rpc.ItemRecRpc)
[ERROR] subtype com.client.rpc.ItemRecRpc.LogCollection is not default instantiable (it must have a zero-argument constructor or no constructors at all) and has no custom serializer. (reached via com.client.rpc.ItemRecRpc)
[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. (reached via com.client.rpc.ItemRecRpc)
[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. (reached via com.client.rpc.ItemRecRpc)
[ERROR] java.util.Collections.UnmodifiableRandomAccessList<T> is not default instantiable (it must have a zero-argument
私のクラスは、のように見えますOKですが、コメントを外すとエラーメッセージが表示されます。それは、
public class LogCollectionRpc implements Serializable {
public LogCollectionRpc() {
//
}
public long creationTime = System.currentTimeMillis();
public LongVector times = new LongVector();
public ArrayList<Object> messages = new ArrayList<Object>();
public int nSkipped = 0; // due to reaching the limit
public int nExceptions = 0; // due to MyAppender-s
public Exception firstException = null; // due to MyAppender-s
public long endGcTime = 0;
public long endTime;
}
そして、私の機能クラスとしてこれを使用しようとするよりも:あなたは私がすべてのサブクラス変数コメントが、私は新しいクラスを作成する場合...とにかく役立つことはできません見るように私は、静的なキーワードで試してみましたOK ...しかし、このことは本当に私の心を悩ましています...
何か考えますか?サブクラスのシリアル化をサポートしていませんか?それとも、私は何かが恋しいです。すべての答えを確認してください。
よろしく、 ピーター
これは@jusioの言うことです:内部ではない静的なクラスは囲むインスタンスを必要とするので、コンストラクタは(コンパイル時に)追加の引数を受け取ります。だから、それはゼロ引数のコンストラクタを持たないことについて不平を言っているのです。この場合、LogCollectionを「パブリック静的クラス」として宣言して、囲むタイプと無関係にすることが最も適切です。または、それを直接新しいファイルに移動することもできます。 'private LogCollection ...'フィールドを削除するのは、GWTがサブタイプを必要としないことを認識して無視するからです。 – helios
真実ですが、それはまたcompailingしているようですが、 "Serializableを実装する" GWTはもう文句を言っていないので、静的で実装しても不平を言うことは不可欠です。奇妙じゃない? – czupe