After years of Java develoment, I was shocked to learn that the compiler doesn’t check if the package name really is the one corresponding to the Java source file’s path.
You can write this:
package abcd;
class Xyz {
}
and it will compile even is Xyz.java is located in efgh folder. I get a warning while editing the file in Netbeans, but that’s about it. In fact, this had led to a bug that was very difficult to spot: http://netbeans.org/bugzilla/show_bug.cgi?id=197320
Any way to get warnings or errors anyway?
With gnu-find, you can search a whole project. cd to the project source root, and then:
You need the pmatchd.sh – script:
If you like it, you will move it to a location in the path, not in the $PWD.