Reputation: 667
I have Test class which has written purely with kotlin
in the library project.
class Test{
@Deprecated(message = "Use other function")
fun testFunction(id: String): Test {
this.testId = id
return this
}
}
I've deprecated testFunction() with Deprecated
annotation. Btw Deprecated
class is under the kotlin package. When i test this deprecated function in kotlin project works as expected(ide shows deprecated warning and strikethrough)
Example: Test(). testFunction("test")
But in the java project it doesn't show warning or strikethrough to function bye ide. When I open the declaration of deprecated function it's like below
@Deprecated(
message = "Use other function"
)
@NotNull
public final Test testFunction(@NotNull String var1) {
Intrinsics.checkParameterIsNotNull(var1, "id");
this.testId = var1;
return this;
}
any help would be appreciated
Upvotes: 1
Views: 1432
Reputation: 23164
In Kotlin, the functions, properties, and classes marked with kotlin.Deprecated
annotation also get the Deprecated attribute in the resulting JVM bytecode. This allows Java compiler to see them as deprecated and emit the corresponding warning.
Take for example this function that is deprecated in Kotlin: https://github.com/JetBrains/kotlin/blob/v1.3.50/libraries/stdlib/common/src/generated/_Ranges.kt#L171-L175 If you try to call it from java as
kotlin.ranges.RangesKt.intRangeContains(null, 1.0);
javac compiler will report the following warning:
Warning:(55, 31) java: intRangeContains(kotlin.ranges.ClosedRange<java.lang.Integer>,double) in kotlin.ranges.RangesKt___RangesKt has been deprecated
and both IDEA and Android Studio will mark it as deprecated as well:
Upvotes: 0