JDK-6351740 : No specification for package-info support
  • Type: Enhancement
  • Component: specification
  • Sub-Component: language
  • Affected Version: 5.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2005-11-17
  • Updated: 2010-04-04
  • Resolved: 2007-06-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6 1.6Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
A DESCRIPTION OF THE REQUEST :
In 5.0, the compiler is supposed to handle annotations on a package declaration using a package-info.java file. I could not find any information about what needs to be done by the compiler to support this.
The only specs I found are really vague and the current implementation of javac (1.5.0_01) doesn't follow that.
The fake interface declaration called package-info is supposed to be synthetic, but the .class file compiled by javac doesn't contain any synthetic information.
It would be nice to clarify the specifications (JLS and/or JVM).
The only mention to package-info is in chapter 7.4.1.1 of the JLS.

JUSTIFICATION :
This would enable other vendors to provide a java compiler that would do the right thing.

Comments
EVALUATION JVMS 3ed chapter 7 includes the text about package-level annotations from the CCC 6232928 specification section (http://ccc.sfbay/6232928). It requires ACC_ABSTRACT + ACC_INTERFACE + ACC_SYNTHETIC. Unfortunately, it turns out that JVM 5.0 does not understand the ACC_SYNTHETIC flag here. 6557865 stops javac from producing 49.0 classfiles with the flag set, and JVMS 3ed 7.14 should sanction 6557865: "When a compiler encounters an annotated package declaration that must be made available at run-time, it must emit an interface (that is, a class file) named package-name.package-info with no superinterfaces. ***When emitting an interface whose class file version is 49.0, the ACC_INTERFACE and ACC_ABSTRACT (��Table 4.1) flags of its ClassFile structure (��4.2) must be set. When emitting an interface whose class file version is greater than 49.0, the ACC_INTERFACE, ACC_ABSTRACT and ACC_SYNTHETIC flags of its ClassFile structure must be set.*** The only elements declared by the interface must be those implied by the Java Language Specification, 3rd edition. The interface has the default access level (���package-private���)."
08-12-2006