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 258472 - NetBeans generates static imports for private elements.
Summary: NetBeans generates static imports for private elements.
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Editor (show other bugs)
Version: 8.1
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-03-21 21:51 UTC by matthies
Modified: 2016-05-30 19:07 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 2016-03-21 21:51:05 UTC
Example:

    public class Example
    {
        { FooBar fb = FooBar.FOO; }

        private enum FooBar { FOO, BAR };
    }

NetBeans proposes to convert "FooBar.FOO" to a static import, which results in a compilation error because FooBar is private.

What's worse, this happens automatically in code completion (typing "FO" and then triggering code completion) when "prefer static imports" is turned on in the options.

The same happens for private static methods.

Expected behavior:
1) Do not propose a static import for elements in a nested private scope.
2) Have code completion complete to the qualified version for elements in a nested private scope even if "prefer static imports" is active.
Comment 1 Svata Dedic 2016-05-24 07:16:21 UTC
You wrote:

> NetBeans proposes to convert "FooBar.FOO" to a static import, which results
> in a compilation error because FooBar is private.

I've tried to make NB display such hint, but failed. Could you please attach example code and your exported Options related to java edititing ? Thanks.
Comment 2 matthies 2016-05-30 19:07:32 UTC
Under Options -> Editor -> Hints -> Language: Java, the hint "JDK Migration Support" -> "Static imports" must be checked. For me it is set to "Warning on Current Line", so you may have to go on the expression "FooBar.FOO" with the caret for the hint to appear.

Please try this. If you still can't reproduce it, I'll provide an example source file and exported options.