Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No way to annotate a package #3600

Open
scabug opened this issue Jun 24, 2010 · 8 comments
Open

No way to annotate a package #3600

scabug opened this issue Jun 24, 2010 · 8 comments

Comments

@scabug
Copy link

scabug commented Jun 24, 2010

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
Copy link
Author

scabug commented Jun 24, 2010

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

@scabug
Copy link
Author

scabug commented Jun 28, 2011

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

@scabug
Copy link
Author

scabug commented Dec 22, 2012

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

@scabug
Copy link
Author

scabug commented Nov 10, 2013

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

@scabug
Copy link
Author

scabug commented Jan 21, 2014

@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
Copy link
Author

scabug commented Jan 21, 2014

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

@scabug
Copy link
Author

scabug commented Jan 21, 2014

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

@som-snytt
Copy link

No one mentioned that this duplicates #3115 with possibly upping the ante on java interop.

@scala scala deleted a comment from scabug Mar 5, 2022
@SethTisue SethTisue added this to the Backlog milestone Mar 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants