Why can one type be assigned to the same validation test?

I run IntelliJ Code Analyzer (IntelliJ 11.1.4) in the class and get this warning:

Unverified job: 'java.util.List' in 'java.util.List'

The code he complains about is:

List<String> targetDocumentIds = pepperWorkflowInstance.getTargetDocumentIds(); 

For reference:

 public class PepperWorkflowInstance<T extends PepperWorkflowInstanceData> implements Serializable { private List<String> targetDocumentIds = new ArrayList<String>(); ... public List<String> getTargetDocumentIds() { return targetDocumentIds; } ... } 

So the types are the same ... so why should I "check" the assignment?

+6
source share
2 answers

Make sure pepperWorkflowInstance has a parameter:

 pepperWorkflowInstance = new PepperWorkflowInstance<SomeClass>(); 

See IDEA-6254 .

+1
source

If pepperWorkflowInstance has a superclass where the raw type is used as the return type, then this message can be generated.

Example.

 class A{ public List getTargetDocumentIds(){ return new ArrayList(); } } class B extends A{ public List<String> getTargetDocumentIds(){ return new ArrayList<String>(); } } public class Tester { public static void main(String[] args) { A a = new B(); List<String> targetDocumentIds = a.getTargetDocumentIds(); // above produces compiler type safety warning } } 
0
source

All Articles