So we have `@JvmSynthetic` to hide Kotlin function...
# announcements
f
So we have
@JvmSynthetic
to hide Kotlin functions from Java users, however, we have no equivalent
@JvmOnly
(or whatever it would be named) to hide definitions from Kotlin. I tried
@Deprecated("Java only", level = HIDDEN)
but it's hidden in Java afterwards as well if you use IntelliJ. 😛 Any known workarounds for this or is a feature request the only possible thing?
f
❤️
🤣
Copy code
@Suppress("ILLEGAL_KOTLIN_VERSION_STRING_VALUE")
@SinceKotlin("Java only")
Seems to be clearer, the suppression can be added as
@file:
too.
m
You might be able to create your own annotation.
@JvmOnlyJava
Otherwise, I'd also use the "Java only" version approach. I know it's unlikely this code will still be around when Kotlin 99999 is released, but...
f
Sadly no, the
@SinceKotlin
annotation is not inheritable. Meaning, if I create a
@JavaOnly
annotation I cannot give it the same semantics as
@SinceKotlin("Java only")
has it and the symbol will be visible in both Java and Kotlin. 😞 I'll create a feature request and PR for Kotlin, we need this. Maybe something like
@PlatformOnly
since it might be useful for JS and native too.
Just wanted to write tests in Kotlin with
@SinceKotlin("Java only")
but the symbols are still visible, it has to be
@SinceKotlin("999999.999999")
or similar (so a version string). 😞 I guess the only workaround here is to create a constant that says
JAVA_ONLY
and contains such a weird number.
m
Interesting....
f
m
Are we deliberately creating our own Y2k here? 😄
f
The reasoning for why devs implemented things as they did that ultimately lead to Y2k were totally sound. Same here. 😉 😄