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 61309 - There should be a hint if the package declaration does not equal to path from root
Summary: There should be a hint if the package declaration does not equal to path from...
Status: VERIFIED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 6.x
Hardware: All All
: P4 blocker (vote)
Assignee: Jan Lahoda
URL:
Keywords:
Depends on: 105054
Blocks:
  Show dependency tree
 
Reported: 2005-07-22 19:30 UTC by athompson
Modified: 2008-09-15 13:41 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 athompson 2005-07-22 19:30:44 UTC
jdk 1.5
linux
daily 21 july 2005

1. create a j2se project.
2. add package 'com.foo'.
3. add class 'Bar' to package 'com.foo'.
4. compile project. the class compiles as it should.
5. in the editor, manually change the package declaration for 'Bar.java' to
'com.bar'.
6! try to build the project. the file is silently ignored, although it is
included in the count shown in the build output. the project compiles successfully.

the problem is not so much that the file was skipped, but that there is no way
for the programmer to know that this file was skipped or why. a warning should
be generated.
Comment 1 Tomas Zezula 2005-07-25 10:48:08 UTC
The changed file from the step 5 is compiled into com.bar package, the original
com.foo.Bar is not deleted until you call Clean And Build Project. The message 1
file compiled is OK, since the Bar was compiled into the new package.
This is right behaviour of javac compiler, you can even have files with diferent
packages in single folder, see spec.
Comment 2 athompson 2005-07-25 12:26:40 UTC
if the file is being compiled properly, then the file is never flagged as
compiled. so the compile icon never goes away and subsequent compiles always
recompile that file, whether it's changed or not. at the least this needs to be
fixed.

also, as i said, the problem isn't that the project compiles, but rather that
there should be a warning. a java file that resides in one package but declares
another valid package usually means the programmer made an error refactoring,
probably when moving the file. at the least it's very bad practice and is
misleading code.
Comment 3 Tomas Zezula 2005-07-25 14:53:04 UTC
Even it is a valid to have the package declaration different to relative path
from the root, there should be probably a warning.
Comment 4 athompson 2005-07-25 15:30:30 UTC
added related issue 61365
Comment 5 athompson 2007-05-21 18:04:13 UTC
still relevant for 6.  marking as a defect since the file is always recompiled
and the 'compile' icon doesn't go away.
Comment 6 athompson 2007-05-29 18:09:13 UTC
a hint has been added, but it needs to be more 'aggressive'.  created issue
105054 to handle this.
Comment 7 Jan Lahoda 2007-07-11 09:28:05 UTC
The hint as such is there. Not sure if there will be more changes for NB6.0, but I do not think it is very important.
Comment 8 athompson 2007-07-13 16:57:16 UTC
whoops, as far as i'm concerned, this is fixed.  the hints being more aggressive is a separate issue.
Comment 9 Max Sauer 2008-09-15 08:59:40 UTC
I consider this issue fixed, since the hint is working and other problems are described in different issue.
Comment 10 athompson 2008-09-15 13:41:59 UTC
yup