Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Re: ajc not enforcing package - directory structure rule

javac does not enforce a one directory per package structure.
If you register several entries into the CLASSPATH and append
several directories with the same name from each of these entries,
you will find that classes scattered throughout all these like-named
directories will behave as if all classes were in the same package.
I tested that a few weeks ago with Sun's javac. I later found out
(from the Yahoo!'s refactoring mailing list
http://groups.yahoo.com/group/refactoring/message/4403) that some
developers use this "feature" to separately manage source files of
different natures within the same package. Examples are JUnit
tests, generated sources files (I would include AspectJ source
files in that category).
I agree with both of you that this feature of javac can be annoying.  I
can never bring myself to write the code to enforce this rule (so ajc
doesn't).  However, we've gotten our fair share of bug reports
complaining about legal behavior that was different from javac's.  We
usually wind up "fixing" these in acknowledgement of javac's position as
a de-facto standard.
This rule combined with the rule that externally visible classes must be
in a file named ClassName.java makes it easy for compilers to find the
correct source file for a given class name without doing any parsing.
This is very useful for javac's dependency-based compilation where you
can point it at Main.java and have all dependencies compiled
automatically.  It can also make implementing incremental compilation
easier.
In AspectJ-1.2, we should add a -warn:packageMatchesDirectory option to
go along with eclipse's other warning options like the one for unused
local variables.  I'm afraid that the default behavior will probably be
to match javac following the principle of least surprise.  However, I'm
almost certain that this will be an option that can be disabled for
those who find the rule silly. -Jim

Miguel J. T. Pessoa Monteiro
Ph.D. student Minho University,Portugal
eMail: mmonteiro@xxxxxxxxxxxxxxxxx
URL:http://gec.di.uminho.pt/mpm/


Back to the top