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

Unavailable Java members from mapping J2K in stdlib #3542

Open
vmishenev opened this issue Mar 19, 2024 · 3 comments
Open

Unavailable Java members from mapping J2K in stdlib #3542

vmishenev opened this issue Mar 19, 2024 · 3 comments
Labels

Comments

@vmishenev
Copy link
Member

interface MyCharSequence: CharSequence

This has chars() and codePoints() members that are absent in https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/ (and in the new documentation too) since they come from mapping (see https://kotlinlang.org/docs/java-interop.html#mapped-types) Java to Kotlin/Kotlin to Java.

The actual DRIs of chars() and codePoints() have thekotlin package so after fixing #3529 they lead to non-existent https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/chars.html and https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/code-points.html

This is also relevant to #2879 (e.g. Dokka generates .../kotlin-stdlib/kotlin.collections/-collection/parallel-stream.html that is a 404-page)

Possible expected behaviour

@vmishenev
Copy link
Member Author

vmishenev commented May 23, 2024

The compiler provides the ability to call methods through Kotlin types that are not declared in them, but are present in platform Java types.

There are 3 kind of declarations that come from mapping J2K in the JVM platform:

  • approved by the Kotlin team;
  • hidden and it is impossible to call them;
  • can be called, but the call will be marked deprecated.

Example:
getFirst is from JDK 21 in java.util.List
image
image

In the first possible solution, Dokka should show only declarations approved by the Kotlin team.

@vmishenev
Copy link
Member Author

The list of such functions with their status is here.
The list of mapped types is here

In K2, there is a class that is responsible for providing a mapped Java scope. Also, see
wrapScopeWithJvmMapped

@vmishenev
Copy link
Member Author

Dokka should filter out filter out such methods from documentation since:

  1. they have no available doc;

  2. In K1, we experience some inconsistencies during the analysis of stdlib.
    For example, Collection does not contain such methods (e.g. spliterator, stream, parallelStream), but its inheritors (AbstractMutableCollection) do. It seems Dokka will have the similar situation in K2.

The long-term solution in K2 is blocked by https://youtrack.jetbrains.com/issue/KT-69796/Analysis-API-Provide-a-way-to-detect-mapped-methods-from-JVM

The short-term one is to support a manual list of such methods in a Documentable filter. e.g. vmishenev/kotlin@8997a9a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant