Question: I have the following interface:

```
public interface Result<T extends Serializable> extends Serializable{
    T getResult();
}

```

With that interface, I can not define a variable of type

```
Result<List<Integer>>

```

because List is not serializable.

However, if I change the interface to this:

```
public interface Result<T> extends Serializable{
    T getResult();
}

```

It now becomes impossible to implement, with compile time checking, because there is no guarantee that T is serializable, and the whole point of the class is to store the result so that I can get it back later, possibly after a transfer over the internet.

My question is this, is there a way to declare a variable so that it is of two types, or is there some other way to do this that I am not seeing? So, maybe something like:

```
(List<Integer> extends Serializable) value = new ArrayList();

```

I am trying to put as much of the burden of this problem on the implementation, so that future consumers of this interface are unaware of the problem.

Thanks for your help!

Here is a more detailed example of what I am trying to do:
I am calling a server, The result of which I want to store in a result object, but I do not want to have to deal with casting. So, each method that can be called on the server will define the type of the result by using generics. This result object will also store other meta-data about the result, for example maybe there was too much information to return. In many cases I want to use a list, but the List interface is not serializable, although many of the implementations are.

So, how to I specify that the type used must be Serializable, but still allow for a List(and not a specific implementation of List) to be used?

Answer: 
The way I ended up solving this problem is to use this as the interface:

```
public interface Result<T> extends Serializable{
    T getResult();
}

```

Then create an implementation for each of the different types of collections as well as one for any object.

So, for example here is what the ListResult class would look like:

```
public class ListResult<T> implements Result<List<T>>{
    public List<T> getResult(){
        //return result
    }

    public <V extends List<T> & Serializable> void setResult(V result){
        //store result
    }
}

```
Initial thought. If you are planning on using serialization for any kind of long term data storage, don't. Serialization is not guaranteed to work between invocations of the JVM.

You probably should not be extending Serializable unless you are adding functionality related to Object serialization. Instead, your class that implements Result should also implement Serializable.