Replies: 1 comment
-
Please try the same with javac (which, too, is a batch compiler) and you won't see it complaining, right? Also, nobody would like to see an error from a compiler invocation like this:
This silly example is to demonstrate that the compiler may not even know, which part of a file path is intended as a package. The the congruence between packages and directories is explicitly not required by JLS. The specification delegates issues like directory layout to what they call "the host system". In Eclipse the IDE is this host system which is entitled to enforce such rules. In your case I would call gradle "the host system", and so you could suggest to gradle that this build system raises such an error, if you can convince them, that this is relevant. We consider neither ecj not javac as "host systems". They just process the files being passed to them. |
Beta Was this translation helpful? Give feedback.
-
When a java file contains the package declaration that doesn't match with the directory it is located in, eclipse editor view correctly flags it as an error - The declared package "xxx" does not match the expected package "yyy". But when I run ecj from command line, the above error is not flagged and the code is compiled successfully. I put together a small gradle project to demo the issue: https://github.com/snagis/eclipse_package_test
Is there any undocumented setting that ecj uses to detect/ignore this error? I can't seem to find any.
Beta Was this translation helpful? Give feedback.
All reactions