Skip to content

Constructor code completion doesn't work after diamond operator for non-JDK classes #9193

@nmatt

Description

@nmatt

Apache NetBeans version

Apache NetBeans 28

What happened

In a new-expression with diamond operator (<>) for a generic class, like new Example<>, code completion to select between constructors works before the diamond operator, but not after it; the popup shows "No suggestions". Strangely, it does work for classes like ArrayList from the JDK. It does not work for in-project classes, or for other dependencies, like for example JAXBElement in javax/jakarta.xml.bind.

Language / Project Type / NetBeans Component

Java, Editor

How to reproduce

In a Java project, add the following class:

public class Example<T> {
    public Example(T value) { }
    public Example(String name, T value) { }
}

Anywhere in the project, in an expression/statement context, enter the partial expression new Example<>. Add an import for the class if necessary.
Invoke code completion before the <> => the popup shows both constructors, and Example<T> as a third entry.
Invoke code completion after the <> => the popup shows "No suggestions".

Add the JAXB API as a dependency and try the same for new JAXBElement<> => same result.

Do the same for (java.util) new ArrayList<> => code completion shows all three constructors both before and after the diamond operator.

Did this work correctly in an earlier version?

No / Don't know

Operating System

Windows

JDK

JDK 21

Apache NetBeans packaging

Apache NetBeans binary zip

Anything else

When adding type parameters, i.e. not using the diamond operator, code completion does work after type-argument list, as in new Example<String>.

Are you willing to submit a pull request?

No

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind:bugBug report or fixneeds:triageRequires attention from one of the committers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions