-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Introduce @ApiMayChange/@DoNotInherit/@InternalApi #7528
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
Conversation
Uplifted from akka.annotation.
27ecb58 to
75d38bc
Compare
|
Thanks, I'm happy to have
On a related note, it'd be interesting to consider our whole story on communicating deprecation / migration / api stability / accessibility, and see about more radical improvements for the 3 series. |
The use cases for
The use cases for
While I welcome such exploration and research, I'd love if we could start with something basic like this, which if need be we can move away from (how meta). |
|
Thanks for fleshing our the use cases.
I don’t mean to require a research paper to land the PR. Sorry if I gave
that impression. I meant more exploration would independently be useful.
I am still concerned about duplicating functionality, especially for (3),
so that does factor in to exploring the design space a bit, and being
conservative with what we add to the stdlib, especially at the root of the
namespace. That stuff sticks around for 10 years.
Sealed classes can be extended within their compilation units. Should be
enough for library use, no?
…On Thu, 20 Dec 2018 at 18:31, Dale Wijnand ***@***.***> wrote:
- @internalapi -- we should improve our compilation scheme for access,
or MiMa's understanding of it, instead (I know this has been a longstanding
issue, so I'm willing to concede that maybe we need an annotation)
The use cases for @internalapi include (for example) marking a method
that must be public so that it may be accessed from a (non-subclass) class
in another package. There's nothing in the bytecode to say that, for cross
Scala/Java communications, so an annotation is the best bet. In a similar
vein to @ApiMayChange I'm proposing putting it in the standard library to
make it ubiquitous in the ecosystem.
- @DoNotInherit -- we already have sealed for that. If the JVM ever
adds support for sealing classes (openjdk.java.net/jeps/181 is
promising), we'd use that to signal the intent to javac.
The use cases for @DoNotInherit require it not to be sealed: the
annotated class is not to be extended by *user-code*.
On a related note, it'd be interesting to consider our whole story on
communicating deprecation / migration / api stability / accessibility, and
see about more radical improvements for the 3 series.
While I welcome such exploration and research, I'd love if we could start
with something basic like this, which if need be we can move away from (how
meta).
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#7528 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAFjy5Jum1I55CscRHpGEV7CFiP6PSfxks5u68mEgaJpZM4ZT68u>
.
|
I'm adding it in the
I assume you mean file. But no, particularly when you end up having multiple packages (javadsl, scaladsl, internal) you end up with multiple files. And sometimes you split those packages into independent jars, so not even the same compilation unit. I wish I had to setup to extract the stats for you on this, from the usage in Akka. |
right, root + 1 -- so, conservative - 1, but still a high-ish amount of conservatism :-)
Yeah, "compilation unit" is specese for file. Fair enough, and this is where I think we get into exploring the design space -- I think it's really interesting to consider separate accessibility for callers and subclassers. |
|
Notes from meeting with Adriaan about this.
My initial intents were to use MiMa to post-process the bytecode to verify and warn or error on incorrect usage, and therefore was only requesting to add these to the standard library. But Adriaan mentioned the compiler could potentially enforce these at compile time, just like But it might be still good to have these annotations present in (what I'm calling) the "java space" of the bytecode, i.e not in the pickler, so that general java bytecode analysing tools could see them. Adriaan, of course, is concerned about additions to the standard library, knowing what it means to remove them afterwards. We also touched on how these annotations are not too dissimilar to Also, as with all changes, as soon as it's accepted you want to be able to use it, but that's not possible in a cross-compiled project (including Scala 2.11). So on balance, I think it's better to rally users around an external library and tooling around this, and later reconsider uplifting one, the other or both into Scala proper. |
Uplifted from akka.annotation.
By having these in the standard library we can make use of them throughout the ecosystem and do things like build tools (like MiMa) upon their usage.
NoteStaticAnnotationstates:andClassfileAnnotationis (freshly) deprecatedso I'm concerned that these might not be seen in MiMa (trivially).Also, I retained the original name, with their upper-case, for Java users.
Finally I put these in the annotation package, as it seemed sensible (and mirrored Akka's original decision).
TODO:
Review (and help wanted) by @lrytz or @adriaanm, kindly.