6

I'm running IntelliJ's Code Analyzer (IntelliJ 11.1.4) on a class and am getting this warning:

Unchecked assignment: 'java.util.List' to 'java.util.List '

The code it 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 match... so why would I need to 'check' the assignment?

5
  • 4
    What type is targetDocumentIds from pepperWorkflowInstance instance? Commented Nov 20, 2012 at 16:31
  • Just realized this is a IntelliJ warning, not JVM. What version of IntelliJ do you have? Commented Nov 20, 2012 at 16:35
  • Made edits to address comments Commented Nov 20, 2012 at 16:47
  • Do not discard a bug in Idea Commented Nov 20, 2012 at 16:48
  • @Luciano I haven't, but I'd like to confirm that I'm not missing something in Java, first Commented Nov 20, 2012 at 16:49

2 Answers 2

1

Make sure that pepperWorkflowInstance has parameter:

pepperWorkflowInstance = new PepperWorkflowInstance<SomeClass>();

See IDEA-6254.

Sign up to request clarification or add additional context in comments.

Comments

0

If the pepperWorkflowInstance is of super class where raw type is used as return type, then that may generate that message.

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                        
    }
}

1 Comment

Thanks, but I'm not sure that applies to my situation... good info though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.