Eclipse for Java syntax checker error for generic arrays [message #1862674] |
Wed, 20 December 2023 03:57  |
Eclipse User |
|
|
|
The following line does not compile by hand manually with javac (JDK21), and does not go past Eclipse syntax checker (JDK-17 compat), which claims its a generic array, which is clearly not, very specifically typed expression.
MyClass<Long>[] longsort = new MyClass<Long>[5];
[Updated on: Wed, 20 December 2023 04:01] by Moderator
|
|
|
|
Re: Eclipse for Java syntax checker error for generic arrays [message #1864956 is a reply to message #1864892] |
Mon, 22 April 2024 01:54  |
Eclipse User |
|
|
|
Woah, that type mismatch is definitely head-scratching! You're right, it should compile. Here's what might be going on:
JDK Version: While you mentioned JDK21 for javac, sometimes Eclipse can have a different version configured. Double-check both versions to ensure compatibility.
Generic Array Syntax: There might be a quirk with how Eclipse handles generic array syntax. Try the following alternative:
Java
MyClass<Long> longsort[] = new MyClass[5];
This rearranges the brackets to explicitly declare the array type first.
If neither of those suggestions work, try creating a minimal reproducible example and posting it on a Java forum like Stack Overflow. Someone might have encountered the same issue with your specific Eclipse setup.
|
|
|
Powered by
FUDForum. Page generated in 0.06354 seconds