apache / netbeans

Apache NetBeans
Apache License 2.0
2.55k stars 813 forks source link

"Fix All Imports" importing invalid static methods #7073

Open TFyre opened 2 months ago

TFyre commented 2 months ago

Apache NetBeans version

Apache NetBeans 20

What happened

Looks like "Fix All Imports" imports invalid static methods when the method name matches an existing import's root package.


Language / Project Type / NetBeans Component

Java Maven Application

How to reproduce

Create Maven Application and set source to 17 or 21 (works fine with 8):




package com.tfyre.test;

import java.util.List;
import javax.xml.parsers.DocumentBuilder;
import org.xml.sax.InputSource;

public class NewClass {

    private List<String> list;
    private DocumentBuilder foo;
    private InputSource is;

    public static class SomeClass2 {

        public static String java(String value) {
            return value;

        public static String javax(String value) {
            return value;

        public static String org(String value) {
            return value;

java -version
openjdk version "21.0.2" 2024-01-16 LTS
OpenJDK Runtime Environment Zulu21.32+17-CA (build 21.0.2+13-LTS)
OpenJDK 64-Bit Server VM Zulu21.32+17-CA (build 21.0.2+13-LTS, mixed mode, sharing)

Did this work correctly in an earlier version?

Apache NetBeans 19

Operating System




Apache NetBeans packaging

Apache NetBeans binary zip

Anything else

Every time

Are you willing to submit a pull request?


TFyre commented 2 months ago

Possibly related to #6902?

TFyre commented 2 months ago

Duplicate of #5537?