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 53419 - No warning about incorrect package declaration
Summary: No warning about incorrect package declaration
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 6.x
Hardware: PC Windows XP
: P2 blocker with 1 vote (vote)
Assignee: Jan Lahoda
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-01-14 18:00 UTC by ddevore
Modified: 2009-01-28 13:33 UTC (History)
2 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ddevore 2005-01-14 18:00:32 UTC
If you change the package name but leave the file
in the old package directory the compiler will not
mark it as an error. It will compile the file to
the location of the package name which confuses
the IDE and forces files that use it to error. It
also forces the fix imports to always want to
import the file from the incorrect location. This
was found when the refactor wizard did not
correctly change the name of the package.
Comment 1 Jesse Glick 2005-01-14 18:57:01 UTC
Well don't change the package name to the wrong value then. Many
things will not work if you do so.

If you can reproduce a problem with the refactoring wizard, please
file it with details (component: refactoring).
Comment 2 ddevore 2005-01-14 19:56:07 UTC
This problem was found when refactoring I DIDN'T CHANGE THE PACKAGE TO
THE WRONG NAME NETBEANS DID. If a file is in a wrong package the IDE
should tell you this. It seems to me that other IDEs and if you want
to compete with other IDEs and "keep people out of the dark" then you
netbeans should strive to be BETTER not worse.

Thank you for your poor non caring response.
Comment 3 Jesse Glick 2005-01-14 20:11:21 UTC
Please stop shouting.

As I said before, if the IDE failed to update the package declaration
correctly during a refactoring (e.g. move class to another package),
that is clearly a bug which should be filed in the refactoring
component, with whatever details to reproduce the problem you can
supply (since I presume NetBeans QA has tried this operation many
times and it worked correctly, so any failure is likely to rely on
something specific about your environment).

Leaving open in Java component (nothing to do with Ant) in case it is
possible to mark a JavaNode with some kind of error badge in case its
package declaration conflicts with its actual location beneath a
source root. I believe JavaNode used to do this, or at least produced
a tooltip or something, but I am not sure of details.
Comment 4 ddevore 2005-01-14 20:27:18 UTC
Sorry to bother you with something that could improve the program.. I
really didn't mean to take any of your time.
Comment 5 Jesse Glick 2005-01-14 21:01:07 UTC
I think this is a valid issue when rephrased - there should indeed be
some warning on the Java node as it is parsed - I just did not
consider that possibility before, since the request was phrased in
terms of the build process, where it is impractical to make any change
(for reasons of performance among others).

As far as the build stage with Ant goes, there is little to be done
because javac will accept files from any structure (with no warnings
about inappropriate package statements) even though in such cases it
will fail to correctly handle transitive compilation dependencies
(which I seem to recall was the gist of another recent issue of yours
- a bad package structure could result in such a problem). Cf. e.g.

http://ant.apache.org/faq.html#always-recompiles

Ideally javac would have some kind of flag which let you request a
warning or error message in case a package declaration did not match
one of a supplied list of source roots, but it doesn't.

All of this is independent of any bugs that may exist in the
refactoring functionality; the IDE always *tries* to set the correct
package statement when making a new class or moving it.
Comment 6 ddevore 2005-01-15 15:11:39 UTC
I found what caused the initial error and am issuing it in the
Refactoring error.. 

If you create a new file in the Source Packages and click/drag a class
into it, it will bring up the "Refactor Code for Move Class" dialog
box under clicking next it says "A package correspondig to the entered
name cannot be found.". Clicking on cancel leaves the file in the
moved directory without the package name being changed. 

At least a simple error indicator on the package line if the file is
not in the correct directory would be nice.

Thanks
Comment 7 ddevore 2009-01-28 13:33:13 UTC
I cannot reproduce this error in 6.5.