bug icon indicating copy to clipboard operation
bug copied to clipboard

No way to annotate a package

Open scabug opened this issue 15 years ago • 8 comments

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.

scabug avatar Jun 24 '10 22:06 scabug

Imported From: https://issues.scala-lang.org/browse/SI-3600?orig=1 Reporter: Alex Hvostov (argv)

scabug avatar Jun 24 '10 22:06 scabug

Gabriel Rossetti (grossetti) said: Yes, this would be nice

scabug avatar Jun 28 '11 07:06 scabug

@paulp said: A meta-annotation should be used to disambiguate between package and package object.

scabug avatar Dec 22 '12 23:12 scabug

Nathan Stoddard (nstoddard) said: This would be very nice to have for the @strictfp annotation, especially for package objects.

scabug avatar Nov 10 '13 16:11 scabug

@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.

scabug avatar Jan 21 '14 14:01 scabug

@xeno-by said: I would like to mention that loading Java-based package annotations via Scala reflection isn't implemented yet.

scabug avatar Jan 21 '14 16:01 scabug

@gzm0 said: Thanks for the info. This won't affect what we propose.

scabug avatar Jan 21 '14 16:01 scabug

No one mentioned that this duplicates https://github.com/scala/bug/issues/3115 with possibly upping the ante on java interop.

som-snytt avatar Mar 05 '22 02:03 som-snytt