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 19923

Summary: Package name can be renamed to a name that contains a space
Product: java Reporter: John Baker <jbaker>
Component: UnsupportedAssignee: issues@java <issues>
Status: CLOSED FIXED    
Severity: blocker    
Priority: P3    
Version: 3.x   
Hardware: PC   
OS: Windows ME/2000   
Issue Type: DEFECT Exception Reporter:

Description John Baker 2002-01-30 02:09:44 UTC
Using EE kit 020124

It shouldn't be allowed to create a package name that contains a space.

To reproduce:
1) Mount a new filesystem
2) Create a new package, "MyPackage"
3) Rename the package to "My Package"

If sources exist in the package then a dialog opens with ...

Package "MyPackage" was renamed to "My Package".  Do you want to change package declarations in Java 
sources inside the package?

Result:
"MyPackage" could be renamed to "My Package"

It is illegal to have a package name that contains a space.
Comment 1 phamernik 2002-01-30 07:50:18 UTC
It is not possible to prevent from renaming folders to the names with
spaces.

I would suggest to change the dialog message when invalid Java package
name is used for folder name.
The warning could say something like: "The new name of package is not
a valid Java package name. .... ". 

As the implementation of this dialog is in Java module, I am changing
the component: core -> java.
Comment 2 John Baker 2002-01-30 19:32:22 UTC
I would expect NB to recognize that I'm renaming a package, not
a folder.  Regardless, I think renaming a folder to a name
that contains a space is a bad thing, it doesn't make any sense.
Comment 3 John Baker 2002-01-30 19:41:18 UTC
The reason why it's bad is that I don't know of any Java programs
that could compile. For a Web Module, if this type of folder is
created in the WEB-INF/Classes directory then the Web module cannot
compile.  If any Java program resides in this type of package in the
name then it can't compile either.
Comment 4 Svata Dedic 2002-02-01 14:35:08 UTC
I disagree that renaming a folder to have a space in the name is
pointless. Under well-behaved OSes, a filename has no restriction on
characters it can contain (except the path separator and sometimes
null char - terminator). On Windows, giving spaced names is convenient
for users, since folder names can be descriptive.
The current IDE's design does not permit checking for valid package
name, preventing the rename operation. I will implement Petr's
suggestion to issue a warning afterwards.
Note that there can be free-named folders (not packages) underneath
the package structure - resources can be here, since ClassLoaders
survive spaces in resource names, but classes can't be in such folders
(since they are not packages).

Comment 5 Svata Dedic 2002-02-15 10:14:28 UTC
Fixed in trunk - a warning is issued after the package name has been
changed to a non-identifier.

/cvs/java/src/org/netbeans/modules/java/PackageHandler.java,v  <-- 
PackageHandler.java
new revision: 1.2; previous revision: 1.1
Comment 6 Jan Becicka 2002-06-27 11:01:39 UTC
VERIFIED
Comment 7 Quality Engineering 2003-07-01 13:19:20 UTC
Resolved for 3.4.x or earlier, no new info since then -> closing.