Not sure if this is a proposal but I haven’t manag...
# language-proposals
p
Not sure if this is a proposal but I haven’t managed to find anything about it. We are migrating code from Java to Kotlin and make heavy use of the JVM annotations. Often we may have the proper Kotlin way of doing things and then create JVM accessors to avoid massive refactors. For instance, we have an object that had an internal representation of the type and we have moved them to be a sealed class (which makes more sense). In Java we had two static factory methods that we used on each case. Now, from Java we have the respective constructosrs for each type. To make the transition easier we have kept the old Java Factory methods (in Kotlin) so that we don’t change thousands of files (there may be fewer) We want to avoid kotlin components calling these methods. Is there any way (no matter how hacky) to make a function that can be called from Java but not from Kotlin? (a bit like the reverse of inline functions)
d
You could use
@Deprecated
with
DeprecationLevel.ERROR
. This will make it an error for Kotlin to call this function (it won't compile) but Java can still use it, it will just have a "normal deprecation".
🙇‍♂️ 2
p
oh! I like that 🙂
r
Also, making it inline isn't the way to stop Java calling in. You should use
@JvmSynthetic
.
1
👍 1