- 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!
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744209114a4563249.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