Community
Participate
Working Groups
Build 2.0 From user: Some developer complained that the Eclipse Java compiler treats an empty '.java' file as an error. They can run into this scenario when adding new '.java' files to source control. If they check in the directory version such that the new '.java' file is visible to other users but they don't check in the first version of the '.java' file itself, the '.java' file shows up as an empty file to all other users. Thus, this breaks the builds of everyone else. Is this the spec'ed behavior for Java compilers. I tried 'javac' from the Sun JDK and it silently skipped empty '.java' files...
This is a valid usecase, will turn off the check for empty units. We might also consider turning this error into a configurable problem (error/warning/ignore), but this might induce confusion down the road. Note that our batch compiler will behave like javac, but the check occurs when the Eclipse Java builder is triggered so as to maintain the source tree consistency (and allow incremental compilation to perform in a predictable fashion).
Backporting to 2.0.1. We will only avoid complaining for empty units (contents length == 0). If containing one space, we will start complaining.
Verified
Verified.
Testing in 2.0.1 build 20020821, I noticed it now does NOT complain even if the file contains only whitespace. This is different behaviour from Philippe's last comment.
John, I am observing the behavior I described in my previous comment. As soon as a space is added, the package error is reported. Can you provide steps to reproduce what you are seeing ?
Create a .java file in the default package. If it contains only whitespace there are no build problems reported.
Verified in 2.1 M1
Also see bug 24529. We made the rule more permissive. No complaint will be issued until some actual structure is added to the unit (package, import or type).