Java Annotations: expected array instead of object
Hello everyone,
I'm a former Eclipse user who wants to get started with IntelliJ IDEA. I'm currently facing an issue that really bugs me.
Assume you have a Unit Test Suite:
@RunWith(Suite.class)
@SuiteClasses({Test1.class, Test2.class}
public class MySuite { }
Now IntelliJ complains that "@RunWith" expects a parameter of type Class[], but it found an element of type Class<?> instead. It's clear to me why this happens, because strictly speaking, @RunWith defines it's "value" to be a class array. However, it is allowed by the Java compiler (and customary for developers) to pass a single object when only one is needed in place of an array.
What I would need to do to satisfy IntelliJ IDEA in this case is:
@RunWith(new Class[]{PackageSuite.class})
... but that's definitly not what I want to do, it's too much syntactic noise and reduces readability while it doesn't provide any additional information.
In Eclipse, this works out-of-the-box. How do I tell IntelliJ that it should not give me errors or warnings in such a case?
Thanks,
Martin
请先登录再写评论。
I'm sorry. I just discovered that apparently my Project SDK version in IntelliJ was not set up properly. Setting it to my Java 1.8 JDK fixed the issue and I no longer get this error/warning.