Skip to content

Encoding.Copy not copy annotation of methods #1652

Description

@Doc94

Hi, i have an Encoding class with a method like this.

@Encoding.Naming("with*OrNull")
@Encoding.Copy
public Possible<Optional<T>> withOrNull(@Nullable T value) {
      return discord4j.discordjson.possible.Possible.of(Optional.ofNullable(value)); //Posible its like an Optional for internal
}

the issue is every class generated with that not include the Nullable from JSpecify

public Builder optionalOrNull(String value) { // not annotation here
      this.optional_possible = Possible.of(Optional.ofNullable(value));
      return this;
}

this cause a few warnings in IDE or mess with kotlin nullability checkers for the use of @NullMarked

Activity

  1. elucash commented on Apr 6, 2026

    @elucash
    Member

    Thank you for reporting this. I don't know if it were ever designed or implemented to copy annotations. This definitely predates any TYPE_USE annotations. I'll see if that can be implemented, but cannot promise that would be soon.

  2. 12345ieee commented on Aug 19, 2026

    @12345ieee

    Has this been solved by #1671 ? If so, is there a published version with that fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions