Now I would like to have a class like this
OperationExecutor<T extends Operation<S>> extends AsyncTask<T,Void,S>{ @Override protected S doInBackground(T... params) { return null; } }
The reason this doesn't work is because S
hasn't been declared anywhere, only referenced as a type argument in T
's bound. Java needs S
to be declared for other references to it to make sense, for example protected S doInBackground
and AsyncTask<T,Void,S>
.
One thing you might consider is whether OperationExecutor
needs to be generic to a specific type of Operation<S>
. You could do this instead for example:
OperationExecutor<S> extends AsyncTask<Operation<S>, Void, S> {
@Override
protected S doInBackground(Operation<S>... params) {
return null;
}
}