bug
bug copied to clipboard
No way to annotate a package
Scala does not have any way of placing annotations on a package.
In Java, package annotations are placed before the package statement in a Java source file named package-info.java. The compiler generates an interface named package-info and attaches those annotations to it. These annotations (if they have a retention policy of RUNTIME) can then be looked at with some methods on java.lang.Package.
See also: [http://java.sun.com/docs/books/jls/third_edition/html/packages.htmlSI-7.4.1.1 JLS 3rd Ed. � 7.4.1.1]
The most obvious syntax for this is to allow annotations on package objects. This might result in confusion, though, since package objects have their own, distinct class files.
Imported From: https://issues.scala-lang.org/browse/SI-3600?orig=1 Reporter: Alex Hvostov (argv)
Gabriel Rossetti (grossetti) said: Yes, this would be nice
@paulp said: A meta-annotation should be used to disambiguate between package and package object.
Nathan Stoddard (nstoddard) said: This would be very nice to have for the @strictfp annotation, especially for package objects.
@gzm0 said: After discussion with Lukas Rytz, we are of the opinion that allowing annotations on package objects and requiring a java source file if (Java-)annotations on packages are required is sufficient.
@xeno-by said: I would like to mention that loading Java-based package annotations via Scala reflection isn't implemented yet.
@gzm0 said: Thanks for the info. This won't affect what we propose.
No one mentioned that this duplicates https://github.com/scala/bug/issues/3115 with possibly upping the ante on java interop.