admin管理员组文章数量:1401233
- OS
- Windows11
- Language
- Java JDK1.8.0_171
- IDE
- IntelliJ IDEA: 2024.3.5
- Cursor: 0.46 installed Java extensions which is recommended
I'm experiencing a problem that does not occur in IntelliJ IDEA but does occur in Cursor (VSCode). In the following code, IntelliJ shows a warning:
Unchecked overriding: return type requires unchecked conversion. Found 'java.util.List<?>', required 'java.util.List'
However, in Cursor, it shows an error and can't build:
The return type is incompatible with IService.voList(List)
The issue occurs in public class ServiceImpl<V>
Here is the code.
package com.example;
import java.util.List;
public class ServiceImpl<V> implements IService<V> {
// other members...
// a warning in IntelliJ and an error in Cursor occur on List<?>
public List<?> voList(List list) {
return null;
}
}
interface IService<V> {
List<V> voList(List<V> list);
}
I want to avoid the error in Cursor and make it behave like IntelliJ, which only gives a warning, because I can't edit this code but still want to open and build it in Cursor. How can I achieve this?
- OS
- Windows11
- Language
- Java JDK1.8.0_171
- IDE
- IntelliJ IDEA: 2024.3.5
- Cursor: 0.46 installed Java extensions which is recommended
I'm experiencing a problem that does not occur in IntelliJ IDEA but does occur in Cursor (VSCode). In the following code, IntelliJ shows a warning:
Unchecked overriding: return type requires unchecked conversion. Found 'java.util.List<?>', required 'java.util.List'
However, in Cursor, it shows an error and can't build:
The return type is incompatible with IService.voList(List)
The issue occurs in public class ServiceImpl<V>
Here is the code.
package com.example;
import java.util.List;
public class ServiceImpl<V> implements IService<V> {
// other members...
// a warning in IntelliJ and an error in Cursor occur on List<?>
public List<?> voList(List list) {
return null;
}
}
interface IService<V> {
List<V> voList(List<V> list);
}
I want to avoid the error in Cursor and make it behave like IntelliJ, which only gives a warning, because I can't edit this code but still want to open and build it in Cursor. How can I achieve this?
Share Improve this question asked Mar 25 at 8:46 luxun1910luxun1910 113 bronze badges 5 |1 Answer
Reset to default 0I've solved it by myself. As someone mentioned in the comment, VSCode(Cursor) uses ecj while IntelliJ uses javac. This problem happens just in ecj (I changed a compiler to ecj in IntelliJ and the same compile error happened). Thank you for your comments!
本文标签: javaUnchecked overriding in IntelliJIDEA but the return type is incompatible in VSCodeStack Overflow
版权声明:本文标题:java - Unchecked overriding in IntelliJ-IDEA but the return type is incompatible in VSCode - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744209114a2595334.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
IService<V>
requiresvoList
to return specifically aList<V>
, but your method is giving it a list of unknown things. Clearly that should not compile. – Sweeper Commented Mar 25 at 9:27List
, or if you implement the rawIService
interface. – Sweeper Commented Mar 25 at 9:29