fabric icon indicating copy to clipboard operation
fabric copied to clipboard

[RFC] Experimental APIs

Open Player3324 opened this issue 5 years ago • 37 comments

In order to support API features that are likely to change (1.16 nether biome selection) or difficult to get right from the start, I am proposing to offer experimental APIs in Fabric API. Those APIs are marked via @Deprecated and can both extend existing modules or form new ones.

The @Deprecated annotation use is in line with how Java annotates its preview features, which serve a similar purpose. Additionally the associated Javadoc has to include @deprecated Experimental feature, may be removed or changed without further notice <optional explanation why it is experimental>.

Addition of and incompatible changes to experimental features will incur a minor version bump, the major version and module version (v0/v1/...) remain the same.

Player3324 avatar Feb 08 '20 21:02 Player3324

I agree, I assume minor gets bumped when adding an experimental API?

modmuss50 avatar Feb 08 '20 21:02 modmuss50

sounds good to me

Prospector avatar Feb 08 '20 21:02 Prospector

Maybe add a special experimental label for experimental PRs?

i509VCB avatar Feb 08 '20 21:02 i509VCB

We may add another annotation targetting classes, fields, and methods to accompany @Deprecated (for easy lookup, added to api base most likely, or use guava @Beta as well)

liach avatar Feb 08 '20 21:02 liach

yes

Ueaj-Kerman avatar Feb 08 '20 21:02 Ueaj-Kerman

Yes

jordanamr avatar Feb 08 '20 21:02 jordanamr

Quick vote: :+1: for guava @Beta annotation etc. in addition to @Deprecated on snapshot hooks :-1: for just @Deprecated on snapshot hooks

liach avatar Feb 08 '20 22:02 liach

Quick reasoning: @Beta alone cannot warn users efficiently. @Deprecated alone cannot distinguish from apis scheduled for release-stage removal or in no-source distributions. Combined would be the most informative.

liach avatar Feb 08 '20 23:02 liach

Another quick note: We talked about jetbrain annotations has annotations like @ApiStatus.Experimental, which may serve notification purposes with ide integration.

liach avatar Feb 09 '20 02:02 liach

Jetbrains Annotations are useful for stuff like ScheduledForRemoval and Experimental, but do IDEs support them?

shedaniel avatar Feb 09 '20 08:02 shedaniel

Here are all of the annotation APIs I know of:

  • JetBrains Annotations - Maven
    • Supported by JetBrains IDEs by default
    • Includes several annotations for APIs (Experimental, Internal, ScheduledForRemoval, AvailableSince, NonExtendable, and OverrideOnly)
    • Includes several other annotations related to compile-time checks, safety, and method contracts
  • @API Guardian - Maven
    • Supported by JetBrains IDEs by default
    • Includes one annotation with an enum for levels of support (INTERNAL, DEPRECATED, EXPERIMENTAL, MAINTAINED, and STABLE)
  • Guava Annotations - Maven
    • Supported by JetBrains IDEs by default
    • Includes one annotation for APIs (Beta)
    • Includes three other annotations related to GWT and testing

I can't speak on Eclipse support as I haven't used it in like six years.

I personally prefer JetBrains Annotations because they allow showing detailed API info and additional optional info.

magneticflux- avatar Feb 25 '20 21:02 magneticflux-

Here are the cons of each:

  • JetBrains Annotations
    • Maybe not interpreted by other IDEs? An annotation processor is preferable.
  • API Guardian
    • Too few associated tools available from official site (e.g. no annotation processor)
  • Guava Annotations
    • No standalone distribution, shipped with guava
    • May conflict with the version of guava vanilla uses

liach avatar Feb 25 '20 21:02 liach

We're taking a lot of the experimental API stuff over to FabLabs. It'll be drafted and worked on there before it's PR'd into Fabric API.

LemmaEOF avatar Apr 22 '20 04:04 LemmaEOF

Imo fablabs will be large experimental apis that are applicable to previous versions (generally applicable).

Snapshot-bound smaller essential apis like nether biomes or living entity attributes may go through fabric directly, I'd suggest, due to a high necessity.

liach avatar Apr 22 '20 05:04 liach

I wonder how feasable it would be to add an @Experimental annotation, should be able to add warnings to that. IDEA does so for Unsafe and similar things.

gudenau avatar May 23 '20 04:05 gudenau

Well we could obviously add an annotation in 2s. The issue is IDE support for these annotations so the user can see something.

i509VCB avatar May 23 '20 04:05 i509VCB

The user visibility imo can be done with an annotation processor that maybe produces a warning if an annotated class/method/field is used in the abstract syntax tree?

liach avatar May 23 '20 18:05 liach

I don't think IntelliJ at least shows warnings from the Annotation Processor in the editing view, I know this because I have gotten Mixin warning that wait to show up until compiling, and then only in the build screen.

TheBrokenRail avatar May 25 '20 22:05 TheBrokenRail

yeah, you need a plugin for AP warnings.

LemmaEOF avatar May 27 '20 21:05 LemmaEOF

All in favor of Jetbrains annotations vote👍 All in favor of literally anything else vote 👎

natanfudge avatar Jun 12 '20 22:06 natanfudge

I prefer JetBrains, because JetBrains IDEs will give a warning, and everything else can be configured to do so easily (or does so by default). Whereas anything else, will not be supported by literally anything.

TheBrokenRail avatar Jun 12 '20 22:06 TheBrokenRail

We need to decide on one annotation standard for ALL projects. This includes yarn, loom, api and loader.

The choice we make imo should be able to support type annotations such as Foo<@Nullable Bar> and Foo.@Nullable Bar

i509VCB avatar Jun 12 '20 22:06 i509VCB

I think you should talk about the different options and the pros and cons before starting a poll like that.

modmuss50 avatar Jun 12 '20 22:06 modmuss50

https://github.com/FabricMC/fabric/issues/499#issuecomment-591084968 https://github.com/FabricMC/fabric/issues/499#issuecomment-591072930 also most the other comments in this issue are that

Ueaj-Kerman avatar Jun 12 '20 22:06 Ueaj-Kerman

This isn’t the right issue for the null checking annotations either. I’d create a new issue about it.

modmuss50 avatar Jun 12 '20 22:06 modmuss50

I mean JetBrains annotations "just work", while other annotations will be more descriptive. @Deprecated doesn't make that much sense, but will show a warning, while @Experimental makes sense, but no warning in the IDE. I prefer having IDE warnings.

TheBrokenRail avatar Jun 12 '20 22:06 TheBrokenRail

Deprecated was chosen as it works in all IDEs not just idea. Java it’s self was using it (I believe the latest version does something else now) for its own experimental APIs so it seemed a great fit.

modmuss50 avatar Jun 12 '20 22:06 modmuss50

@sfPlayer1 Now that we are on java 16, a notable new feature is that @Deprecated now has a forRemoval boolean field. Should we start using those in fabric api now?

liach avatar May 18 '21 02:05 liach

I think so, see https://openjdk.java.net/jeps/277 - "the API is experimental and is subject to incompatible changes"

Player3324 avatar May 18 '21 15:05 Player3324

See #1459 where I add forRemoval for apis that are definitely getting removed in the future.

Meanwhile, for actual experimental apis, I suggest a new review mechanism: We do not need as throughout review for new-generation apis. We would instead add them with @ApiStatus.Experimental and @Deprecated, and have the review for normalization of new api in another pr (we can object or change an api to be forRemoval=true there).

liach avatar May 18 '21 16:05 liach