The usecase is the following, I have a generic class as follows:
public class Test<T> implements Serializable {
private T testObject;
.....
}
With sonarLint off course complaining about the field testObject should be made either transient or serializable.
If I would make the required/proposed change as follows:
public class Test<T extends Serializable> implements Serializable {
private T testObject;
.....
}
Although if I want to make use of this Generic Test class, then I can't use it together with interface types like for example a List interface, because a List is of course not Serializable.
This doesn't compile, but is in my opinion the preferred way programming to the interface.
public Test<List<String>> doSomething() {
}
This compiles, but is actually not what I want...
public Test<ArrayList<String>> doSomething() {
}
So, not sure what the answer to my question is.... should I ignore the SonarLint warning or is there a different way to solve/bypass this?