JDK-6480737 : package-info.java should be compiled if any class in the package is
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Not an Issue
  • OS: generic
  • CPU: generic
  • Submitted: 2006-10-11
  • Updated: 2010-07-29
  • Resolved: 2006-10-11
Related Reports
Relates :  
Description
If I have a package containing some classes and if there is a package-info.java in that package that has annotations, then I would expect that compiling any class in the package would cause the package-info.java to be compiled too.  Currently this does not happen, which means that code that depends on the package will only see the annotation if the package-info.java file was compiled explicitly.  This is inconsistent with the usual behaviour of javac, which compiles every dependency starting from any source file.  Furthermore, there is no way for a Java source file to cause this to happen by referencing package-info explicitly, since package-info is by design not a valid Java identifier.

Comments
EVALUATION The issue of implicitly loaded source files was carefully considered during the development of the JSR 269 RI in javac. Unfortunately, we were unable to find a good model for how to handle implicitly loaded source files and this led us to add the -implicit option to javac. See the manual page: Pre-release location: http://download.java.net/jdk6/docs/technotes/tools/solaris/javac.html#implicit Final location: http://java.sun.com/javase/6/docs/technotes/tools/solaris/javac.html#implicit Loading sources implicitly during annotation processing is not recommended behavior as it may lead to compiling some source files without subjecting them to annotation processing.
11-10-2006