juancho
11/17/2018, 6:54 PMclass Foo(val bar: Int = 1)
how do I get the value 1
?natpryce
11/25/2018, 10:11 AMv79
12/05/2018, 9:03 PMGeneratorPipeline
. Given a String array of class names, I'd like the corresponding array of KClass objects.
But this fails on line 7 processorPipeline.add(kClass)
as kClass
is of type KClass<out Any!>
. Any ideas? Loosening the array processorPipeline = arrayListOf<KClass<*>>()
is OK, but ultimately I need Array<KClass<GeneratorPipeline>>
Marc Knaup
12/06/2018, 12:21 AM/**
* JVM internal name of the class, where package names are separated by '/', and class names are separated by '$',
* for example: `"org/foo/bar/Baz$Nested"`
*/
val ClassName.jvmInternalName: String
get() =
if (this.isLocal) substring(1)
else replace('/', '$')
Isn't it supposed to replace .
with $
, not /
with $
?Marc Knaup
12/10/2018, 11:33 PMval m = JSONParser::class.java.getAnnotation(Metadata::class.java)
but this returns `null`:
val m = JSONParser::class.findAnnotation<Metadata>()
🤔christophsturm
12/11/2018, 8:25 PMdiesieben07
12/29/2018, 3:09 PMval x: MutableCollection<String> get() = TODO()
fun main() {
println(MutableCollection::class) // prints "class kotlin.collections.Collection
println(Set::class.isSubclassOf(MutableCollection::class)) // prints true, should be false
println(::foo.returnType) // prints kotlin.collections.MutableCollection<kotlin.String>, yay!
println(::foo.returnType.classifier) // prints kotlin.collections.Collection, :(
}
Is there any way to figure out if a KType represents a mutable collection type?DALDEI
01/05/2019, 3:32 PMDavide Giuseppe Farella
01/21/2019, 10:27 AMKFunction
and I’m wondering why only Jvm has instanceParameter
and valueParameters
. How does that work on Native? Should I suppose all the parameters
are valueParameters or maybe it’s just not implemented yet and I should distinct them by myself ( how? ) ?
P.S. I don’t know much about Native, that’s the reason of the dumb questiongroostav
01/25/2019, 10:35 AMSomeClass::main
into a classname for a java -mainClass
argument. This is the best I've got
private val KFunction<*>.instanceTypeName: String get() {
return ((this as FunctionReference).boundReceiver::class as KClass<*>).jvmName
}
usage:
val mainClass: String = (MyType::main).instanceTypeName
is there a better solution?dmcg
02/12/2019, 11:31 AMKFunction0
by applying a receiver to a KFunction1
returned from this::class::memberFunctions
- is that possible?diesieben07
02/13/2019, 11:20 PMNikky
02/27/2019, 12:19 PMException in thread "main" java.lang.IllegalArgumentException: object is not an instance of declaring class
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
dewildte
02/27/2019, 11:35 PMLeoColman
03/04/2019, 6:36 PMClass.forName("myClass").declaredMethods.map { it.kotlinFunction!! }.filter { fn -> fn.parameters.any { it is KFunction<*> } }
but it didn't workjdiaz
03/05/2019, 11:23 AMMarc Knaup
03/05/2019, 7:38 PMtypeOf
is coming soon 😄
Goodbye type tokens!
https://youtrack.jetbrains.com/issue/KT-29915#focus=streamItem-27-3323738.0-0pniederw
03/08/2019, 11:31 PMjava.lang.Class<*>
? Can't find a way to make the type checker happy.groostav
03/13/2019, 7:52 PMgregorbg
06/03/2019, 3:06 PMclass MyClass<E: Enum<E>>(val name?) {
fun read(source: MagicalStringSupplier): E? = source.read()?.let { enumValueOf(it) }
}
I fully understand that the above example does not compile because the type of E
is a class type parameter that gets erased during runtime. I fully appreciate that there is no way to reify E
currently, but perhaps there's a more "dirty" way involving passing around a KClass<E>
or (worst case) even a Java Class<E>
?
We badly need such a feature when reading configurations from files, so that we don't have to constantly convert strings to enums all the time 😇Pickle
06/24/2019, 5:49 PMSrSouza
07/28/2019, 5:31 PMval setter = prop.setter.apply { isAccessible = true } // line 52
setter.call( // line 53
instance,
adapter(
instance,
prop,
if (any is Number) fixNumberType(prop, any) else any
)
dmcg
08/03/2019, 9:55 PMDALDEI
08/09/2019, 2:15 AMDariusz Kuc
09/12/2019, 6:20 PMprintln({}::class.simpleName)
-> null
Java 8 + Kotlin 1.3.40+ -> automatically generates numeric names "1"
(and increments it for subsequent anonymous classes)
Java 11 -> null
pniederw
09/18/2019, 11:34 PMnils
10/02/2019, 5:17 PMSomeClass<Type>
into SomeClass<*>
). However, I'd expect type checks such as the one outlined below to correctly yield true
.
I'd like to ask if the below code snippet is a mistake on my end or if it's related to some kind of bug related to invariances. Thank you.ildar.i [Android]
01/09/2020, 10:53 AMjava.lang.IllegalAccessException: Class clean.db.entities.LocalizationDbEntityKt can not access a member of class infin.api.core.legal.entities.auth.login.LocalizationFromServer with modifiers "private final"
fun LocalizationFromServer.toList() = LocalizationFromServer::class.java.declaredFields.map {
LocalizationDbEntity(it.name, it.get(this)?.toString())
}
Cah anyone help pls?int02h
01/10/2020, 11:59 AM@Metadata
annotation? Because I can extract class member original names even if ProGuard/R8 has obfusacted the class.
Does it make reverse engineering easier because bytecode of the class contains information about its members in @Metadata
annotation?Eugen Martynov
03/18/2020, 4:28 PMjava.lang.AssertionError: Built-in class kotlin.Any is not found
Or it is fixed already?Eugen Martynov
03/18/2020, 4:28 PMjava.lang.AssertionError: Built-in class kotlin.Any is not found
Or it is fixed already?udalov
03/22/2020, 1:08 PM**/*.kotlin_builtins
files, since that's where metadata for these classes is locatedEugen Martynov
03/25/2020, 2:40 PM