Skip to content

Conversation

0marperez
Copy link
Contributor

Issue #

N/A

Description of changes

Adds annotation to indicate when a deprecated API will be removed.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@0marperez 0marperez added the no-changelog Indicates that a changelog entry isn't required for a pull request. Use sparingly. label Sep 19, 2025

This comment has been minimized.

1 similar comment

This comment has been minimized.

@0marperez 0marperez marked this pull request as ready for review September 19, 2025 19:06
@0marperez 0marperez requested a review from a team as a code owner September 19, 2025 19:06
* Any code using this API should migrate to the suggested replacement as soon as possible.
*/
@RequiresOptIn(
message = "This API is deprecated and will be removed in an upcoming minor version.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Can we use major and minor in this message to indicate which minor version the API will be removed in?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we could inherit from annotation classes, maybe, but Kotlin doesn't allow us to do so. Unless you know a workaround.

message = "This API is deprecated and will be removed in an upcoming minor version.",
level = RequiresOptIn.Level.WARNING,
)
public annotation class DeprecatedUntilVersion(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DeprecatedUntilVersion makes it sound like we'll be un-deprecating this API after X version. What if we called it DeprecatedPendingRemoval?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I agree. When I first read our doc about the annotation, it reads like the annotation is meant to do that. I'd like for @ianbotsf to chime in. I personally like @UpcomingDeletion, @WillBeRemoved, or something similar. We shouldn't need to include anything about deprecation because the @Deprecated annotation will also always be included.

This is a slightly bigger change than it seems by the way. I'll need to update the annotation regex and searches in a few places.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, if we need to keep @Deprecated then including ...Deprecated... in the new annotation feels redundant. I like @PendingRemoval

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, we don't need use the word "deprecated" twice. I don't love "upcoming deletion" or "will be removed" because they sound like promises and might imply a definitive timeline to callers. "Pending removal" sounds better but I think I'd prefer @PlannedRemoval.

message = "This API is deprecated and will be removed in an upcoming minor version.",
level = RequiresOptIn.Level.WARNING,
)
public annotation class DeprecatedUntilVersion(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible for this to extend / implement Deprecated so we don't need two annotations?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless you know some workaround, we can't extend @Deprecated. Kotlin doesn't allow us to do that. We can "implement" deprecated again but that doesn't seem ideal. It doesn't seem like we can fully implement the same functionality ourselves.
https://github.com/JetBrains/kotlin/blob/2.2.20/libraries/stdlib/src/kotlin/Annotations.kt#L36

message = "This API is deprecated and will be removed in an upcoming minor version.",
level = RequiresOptIn.Level.WARNING,
)
public annotation class DeprecatedUntilVersion(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, we don't need use the word "deprecated" twice. I don't love "upcoming deletion" or "will be removed" because they sound like promises and might imply a definitive timeline to callers. "Pending removal" sounds better but I think I'd prefer @PlannedRemoval.

* Any code using this API should migrate to the suggested replacement as soon as possible.
*/
@RequiresOptIn(
message = "This API is deprecated and will be removed in an upcoming minor version.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Hopefully this doesn't happen for a while, but we may make a major version bump that deletes APIs, so this message should probably just say "... scheduled for removal in an upcoming minor version"

This comment has been minimized.

Copy link

Affected Artifacts

Changed in size
Artifact Pull Request (bytes) Latest Release (bytes) Delta (bytes) Delta (percentage)
runtime-core-jvm.jar 835,526 834,754 772 0.09%
http-client-jvm.jar 347,817 347,830 -13 -0.00%

@0marperez 0marperez changed the title misc: deprecatedUntilVersion annotation misc: plannedRemoval annotation Sep 22, 2025
@0marperez 0marperez merged commit 4e12181 into main Sep 22, 2025
20 checks passed
@0marperez 0marperez deleted the deprecated-until-version branch September 22, 2025 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog Indicates that a changelog entry isn't required for a pull request. Use sparingly.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants