https://kotlinlang.org logo
#announcements
Title
# announcements
p

Paul Woitaschek

11/09/2017, 1:26 PM
class.name
?
c

Czar

11/09/2017, 1:28 PM
Copy code
class SomeClass {
    val name = // ???
}
s

stan0

11/09/2017, 1:32 PM
I think @Paul Woitaschek meant
SomeClass.name
or something similar
p

Paul Woitaschek

11/09/2017, 1:33 PM
Copy code
class SomeClass {
  val name = javaClass.name
}
👍 1
s

snrostov

11/09/2017, 2:03 PM
javaClass
is deprecated in favor
::class.java
?
c

Czar

11/10/2017, 6:59 AM
@Paul Woitaschek, thanks, it worked @snrostov it's
val name: String = javaClass.name
vs
val name: String get() = this::class.java.name
and I haven't seen any deprecation warning anywhere regarding javaClass, have I missed something?
s

snrostov

11/10/2017, 7:07 AM
Oh, yes. I'm wrong. Only
KClass<T>.javaClass
is depricated.
Copy code
@Deprecated("Use 'java' property to get Java class corresponding to this Kotlin class or cast this instance to Any if you really want to get the runtime Java class of this implementation of KClass.", ReplaceWith("(this as Any).javaClass"), level = DeprecationLevel.ERROR)
This is in 1.2
And jsClass is javascript is deprecated too.
Copy code
@Deprecated("Use class literal and extension property `js` instead.", replaceWith = ReplaceWith("this::class.js"),
c

Czar

11/10/2017, 10:14 AM
Oh, I haven't played with 1.2 yet.
2 Views