Why IntelliJ gives red errors when source compiled fine?
Hi there,
Attached please find a strippled down java-demo case that I have. This project (4 java files) compiles under Oracle JDK6 using Maven. The IntelliJ IDEA (12 CE) also able to "Make" the project without errors. However when I open the FooMain.java file in editor, it shows a RED error line that says something like "The parameter can not be applied". So I have two questions:
1) Why IntelliJ proceed to tell me RED errors when the source files compiled fine? Is this a bug or expected? I am using default settings from the IDEA CE 12.0, and I have not change any validation rules.
2) I understand that the provided Java demo code is not the best way to use generics, but it compiles and I am not able to change the similar usage in my real code due to many reasons. So now, how do I disable this RED error in IntelliJ so I can view the rest of the project code without hindering?
Thanks,
Zemian
Attachment(s):
java-demo.zip
Please sign in to leave a comment.
Just for the convenience of other community members here's the minimal sample:
The code is compilable, but IntelliJ IDEA highlights red:

This sample is rather tricky. For example if you remove generic from FooGenerator class this code won't be compilable and IDE's highlighting will become correct, although such a change touches neither process() method signature nor its invocation. So probably original compilable code is a bug of Java compiler.
The best way to get both compilable and 'green' code in the IDE is to define process() method like this:
public void process(Class<? extends AFoo> cls) {}Hi Alex,
I already mentioned that I can't modify the source due to politic reasons. As I said, leave the "bad code" aside, the IntelliJ should NOT give me red errors when the code compiled without problems. To me it's an IDE bug.
http://youtrack.jetbrains.com/issue/IDEA-97952