netbeans icon indicating copy to clipboard operation
netbeans copied to clipboard

"Fix All Imports" importing invalid static methods

Open TFyre opened this issue 1 year ago • 0 comments

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.

image

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):

pom.xml:

<maven.compiler.source>21</maven.compiler.source>

NewClass.java

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

Windows

JDK

Zulu21.32+17-CA

Apache NetBeans packaging

Apache NetBeans binary zip

Anything else

Every time

Are you willing to submit a pull request?

Yes

TFyre avatar Feb 16 '24 10:02 TFyre