apache / apache/netbeans

Code completion for anonymous class construction doesn't use diamond operator in Java 9+

Open
#9,295 1 comment 1 reaction 0 assignees View on GitHub
Java kind:bug needs:triage
Dominant language
Java
Stars
3.1k
Forks
935
Avg merge
2d 3h
Merged PRs (30d)
17

Description

### 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
{
abstract T foo();

static
{
Example> example = new Example
}
}
```
Invoking code completion results in unnecessarily repeating the type argument:
```java
Example> example = new Example>() {
...
};
```
Expected result for source level ≥ 9:
```java
Example> 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

Contributor guide

Open the contributing guide

Research direction

Reproduce the example in Apache NetBeans 29 with Java source level 9 or later and follow the Java code-completion entry point for anonymous class construction. Compare the inserted constructor with the expected diamond-operator form, then verify completion still repeats type arguments for older source levels and uses <> for source level 9+.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.