obender
11 Jun 2008, 10:58 AM
Let say there is a following class:
public class DataRow implements Serializable
{
public void addValue( Object o ) {
values.add( (Serializable)o );
}
public Object getValue( int idx ) {
return values.get( idx );
}
private List<Serializable> values = new ArrayList();
}
And here is the service:
public interface TestService extends RemoteService {
// Sample interface method of remote interface
DataRow getDataRow();
}
public class TestServiceImpl extends RemoteServiceServlet implements TestService {
// Implementation of sample interface method
public DataRow getDataRow()
{
DataRow dr = new DataRow();
dr.addValue( "xxx" );
dr.addValue( new Date() );
return dr;
}
}
I'm getting serialization warnings when I call the service from my code.
It is different every time but in goes somewhat like this:
...
Analyzing the fields of type 'lient.DataRow' that qualify for serialization
private java.util.List<java.io.Serializable> values
java.util.List<java.io.Serializable>
Checking type argument 0 of type 'java.util.List<E>' because it is directly exposed in this type or in one of its subtypes
java.io.Serializable
Analyzing subclasses:
java.util.LinkedHashSet<E> <-- this is different from time to time
Checking parameters of 'java.util.LinkedHashSet<E>'
Checking param 'E'
Checking type argument 0 of type 'java.util.LinkedHashSet<E>' because it is directly exposed in this type or in one of its subtypes
java.lang.Object
In order to produce smaller client-side code, 'Object' is not allowed; consider using a more specific type
Any suggestions on how to implement heterogeneous serializable containers?
public class DataRow implements Serializable
{
public void addValue( Object o ) {
values.add( (Serializable)o );
}
public Object getValue( int idx ) {
return values.get( idx );
}
private List<Serializable> values = new ArrayList();
}
And here is the service:
public interface TestService extends RemoteService {
// Sample interface method of remote interface
DataRow getDataRow();
}
public class TestServiceImpl extends RemoteServiceServlet implements TestService {
// Implementation of sample interface method
public DataRow getDataRow()
{
DataRow dr = new DataRow();
dr.addValue( "xxx" );
dr.addValue( new Date() );
return dr;
}
}
I'm getting serialization warnings when I call the service from my code.
It is different every time but in goes somewhat like this:
...
Analyzing the fields of type 'lient.DataRow' that qualify for serialization
private java.util.List<java.io.Serializable> values
java.util.List<java.io.Serializable>
Checking type argument 0 of type 'java.util.List<E>' because it is directly exposed in this type or in one of its subtypes
java.io.Serializable
Analyzing subclasses:
java.util.LinkedHashSet<E> <-- this is different from time to time
Checking parameters of 'java.util.LinkedHashSet<E>'
Checking param 'E'
Checking type argument 0 of type 'java.util.LinkedHashSet<E>' because it is directly exposed in this type or in one of its subtypes
java.lang.Object
In order to produce smaller client-side code, 'Object' is not allowed; consider using a more specific type
Any suggestions on how to implement heterogeneous serializable containers?