netbeans icon indicating copy to clipboard operation
netbeans copied to clipboard

Fix All Import suggesting unused import (wicket-bootstrap-extensions)

Open r1gm opened this issue 2 years ago • 3 comments

Apache NetBeans version

Apache NetBeans 16

What happened

When using Fix Import Feature

image

this import suggestion always come out.

image

How to reproduce

See What happened

Did this work correctly in an earlier version?

No / Don't know

Operating System

Windows

JDK

17

Apache NetBeans packaging

Apache NetBeans provided installer

Anything else

No response

Are you willing to submit a pull request?

No

Code of Conduct

No

r1gm avatar Feb 20 '23 04:02 r1gm

this would need a minimal reproducer. It is not clear what is wrong there.

mbien avatar Aug 10 '23 00:08 mbien

ImportTestCase.zip

Hi, hope this help.

r1gm avatar Aug 10 '23 05:08 r1gm

Thanks. So, ~its ant-project specific and~ this only happens in the test project when the language level is set to JDK 9+.

Interestingly, it does not offer the import if it has something else to fix. If i remove the BigDecimal import and use the action it will work fine, the second invocation will offer this weird class.

also happens with maven, all what is needed is the dependency:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.mycompany</groupId>
    <artifactId>mavenproject2</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
    </properties>
    <dependencies>
        <dependency>
            <groupId>de.agilecoders.wicket</groupId>
            <artifactId>wicket-bootstrap-extensions</artifactId>
            <version>7.0.0</version>
        </dependency>
    </dependencies>
</project>
import java.math.BigDecimal;

public class ImportTestCase {
    public static void main(String[] args) {
        new BigDecimal(1);   // run fix imports action
    }
}

mbien avatar Aug 10 '23 20:08 mbien