You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by "nmatt (via GitHub)" <gi...@apache.org> on 2026/03/25 19:06:30 UTC
[I] Code completion for anonymous class construction doesn't use diamond operator in Java 9+ [netbeans]
nmatt opened a new issue, #9295:
URL: https://github.com/apache/netbeans/issues/9295
### Apache NetBeans version
Apache NetBeans 29
### What happened
Since Java 9, the constructor calls for a parameterized anonymous class can use the diamond operator instead of repeating the type arguments. However, NetBeans code completion still inserts the type arguments.
### Language / Project Type / NetBeans Component
Java
### How to reproduce
Example:
```java
abstract class Example<T>
{
abstract T foo();
static
{
Example<ThreadLocal<StackTraceElement>> example = new Example
}
}
```
Invoking code completion results in unnecessarily repeating the type argument:
```java
Example<ThreadLocal<StackTraceElement>> example = new Example<ThreadLocal<StackTraceElement>>() {
...
};
```
Expected result for source level ≥ 9:
```java
Example<ThreadLocal<StackTraceElement>> example = new Example<>() {
...
};
```
### Did this work correctly in an earlier version?
No / Don't know
### Operating System
Windows
### JDK
21
### Apache NetBeans packaging
Apache NetBeans binary zip
### Anything else
_No response_
### Are you willing to submit a pull request?
No
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [I] Code completion for anonymous class construction doesn't use diamond operator in Java 9+ [netbeans]
Posted by "pedro-w (via GitHub)" <gi...@apache.org>.
pedro-w commented on issue #9295:
URL: https://github.com/apache/netbeans/issues/9295#issuecomment-4735558720
AFAICS it's the `abstract` that causes it, for example
```
public abstract class Toolkit<T>{
Toolkit<String> s = new Toolkit |
}
```
does the same (also NB does not offer to do diamond inference later which it normally would.)
`public class Toolkit<T>` is OK, `public interface Toolkit<T>` is not.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists