This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 192371 - Fix Import is not idempotent
Summary: Fix Import is not idempotent
Status: REOPENED
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 7.0
Hardware: PC Windows XP
: P3 normal with 1 vote (vote)
Assignee: Svata Dedic
URL:
Keywords:
: 192882 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-11-23 20:54 UTC by matthies
Modified: 2016-07-18 20:45 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description matthies 2010-11-23 20:54:03 UTC
Example:

    import java.net.BufferedInputStream;

    public class Example
    {
        BufferedInputStream stream;
    }

Performing Fix Imports once results in:

    import java.io.BufferedInputStream;
    import java.net.BufferedInputStream;

    public class Example
    {
        BufferedInputStream stream;
    }

Performing it a second time then results in:

    import java.io.BufferedInputStream;

    public class Example
    {
        BufferedInputStream stream;
    }

Fix Imports should give the second result right away, since by adding java.io.BufferedInputStream it already knows that java.net.BufferedInputStream is unused.
Comment 1 matthies 2010-11-23 21:01:07 UTC
Same for using the "Add import..." hint instead of Fix Imports in the example, by the way: "Add import" should remove the faulty import it is replacing.
Comment 2 Jan Lahoda 2010-12-06 13:13:47 UTC
*** Bug 192882 has been marked as a duplicate of this bug. ***
Comment 3 Svata Dedic 2013-09-04 14:53:20 UTC
Disagree with the note about "Add import". Since the hint describes itself as "Add", it should not remove or optimize import statements. It is the job of Fix imports or Organize imports to analyze/remove extraneous statements.
Comment 4 matthies 2013-09-04 16:50:03 UTC
(In reply to Svata Dedic from comment #3)
> Disagree with the note about "Add import". Since the hint describes itself
> as "Add", it should not remove or optimize import statements. It is the job
> of Fix imports or Organize imports to analyze/remove extraneous statements.

The comment is probably obsolete, because no "Add import" hint is shown anymore for the example (tested with 7.3.1).
Comment 5 Martin Balin 2016-07-07 07:15:55 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss
Comment 6 matthies 2016-07-18 20:45:49 UTC
Still reproducible in current dev build.