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 240979 - Java hints to detect possible new imports does not work when a private duplicate exists
Summary: Java hints to detect possible new imports does not work when a private duplic...
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 7.4
Hardware: PC Linux
: P3 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-26 16:41 UTC by markt1964
Modified: 2014-01-31 02:39 UTC (History)
0 users

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 markt1964 2014-01-26 16:41:15 UTC
Some package-private classes exist inside of the jdk which have duplicate names to public ones that are in different packages.  It appears that if one relies on the hinting system to find missing imports, and tries to use a public class where a package-private duplicate exists , instead of offering a hint to import the public one, the hint system declares that the class is not public, and cannot be accessed outside of that package.

To replicate:
1) With a class name that happens to be both package-private and public in different packages which are both visible to a java program, such as java.lang.CharacterData (package-private) and org.w3c.dom.CharacterData (public), enter what would otherwise be valid code using the desired public class using just the class name, without importing it first.

2) Wait a moment for the hint system to detect that the class has not been imported yet.

3) Note that instead of having options to add the necessary missing import statement to the top of the file, an error indicates that the class cannot be used outside of the package, presumably the first one that the hint system found when searching for the class name through visible packages.

Desired behavior:
The hint system would detect that the class is public in another package, and would prompt the user to add the necessary missing import, as it does in the typical case, and only fall back to the error about not being usable outside of the package if the class name was not actually declared as public anywhere else.

Workaround:
Not relying on the hint system to reliably import missing classes
Comment 1 Svata Dedic 2014-01-28 18:31:02 UTC
Implemented in jet-main#991e9d20175c
Comment 2 Quality Engineering 2014-01-31 02:39:32 UTC
Integrated into 'main-silver', will be available in build *201401310001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/991e9d20175c
User: Svata Dedic <sdedic@netbeans.org>
Log: #240979: hooked import fix to inaccessible type, so potentially accessible one can be imported