No error if source directory and package doesn't match
Hello,
I am using Sun's jdk1.5.0_09 "javac" compiler and the package name in my Test class is written as "com.hrishijoshi.asdf". This file compiles even if I put it in a directory called "com" (or anything else, as a matter of fact).
javac doesn't throw error even if the source file's directory structure doesn't match the package name defined in that file! It creates a directory structure matching the package name (not the source tree) in the output "classes" directory.
Is this a feature or a bug? ;-)
- Hrishi Joshi.
PS: Here is a log of my compilation attempt on Fedora Core 5 Linux:
[hrishi@hrishi test]$
[hrishi@hrishi test]$ rm -rf classes/com/
[hrishi@hrishi test]$ cat src/com/Test.java
package com.hrishi.asdf;
publicclass Test{
}
[hrishi@hrishi test]$ javac -Xlint:all -sourcepath src -d classes src/com/Test.java
[hrishi@hrishi test]$
[hrishi@hrishi test]$ tree classes
classes
`-- com
`-- hrishi
`-- asdf
`-- Test.class
3 directories, 1 file
[hrishi@hrishi test]$

