snowe
02/15/2017, 11:27 PMpabl0rg
02/20/2017, 10:33 AMpabl0rg
02/20/2017, 10:35 AMdmcg
02/27/2017, 1:57 PMthis.javaClass
didn’t have the out
variance?adambl4
05/10/2017, 1:21 PMNotImplementedError
since 1.1.2
. Is this somewhere documented?
test<Boolean>()
inline fun <reified T : Any> test() {
when(T::class) {
Boolean::class -> {}
else -> throw NotImplementedError()
}
}
kirillrakhman
05/24/2017, 3:52 PMkirillrakhman
05/24/2017, 3:53 PMabstract class KnowsChildrenTypes() {
companion object {
val types = mutableSetOf<Class<out KnowsChildrenTypes>>()
}
init {
types += this::class.java
}
}
class Child1 : KnowsChildrenTypes()
class Child2 : KnowsChildrenTypes()
pniederw
05/24/2017, 11:59 PMClass
has undesirable side effects (e.g. kotlin.String -> java.lang.String)deinspanjer
05/27/2017, 3:46 PMobj::class.simpleName
, and it said I needed to add the reflection jar to do that. I added it to my Maven Dependencies, but now, when I try to run, I get this error, even if I take out the ::class thing and leave my code just as it was when it runs without the reflection jar:
Exception in thread "main" java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
kotlin/reflect/jvm/internal/ReflectionFactoryImpl.function(Lkotlin/jvm/internal/FunctionReference;)Lkotlin/reflect/KFunction; @5: invokestatic
Reason:
Type 'kotlin/jvm/internal/FunctionReference' (current frame, stack[2]) is not assignable to 'kotlin/jvm/internal/CallableReference'
Current Frame:
bci: @5
flags: { }
locals: { 'kotlin/reflect/jvm/internal/ReflectionFactoryImpl', 'kotlin/jvm/internal/FunctionReference' }
stack: { uninitialized 0, uninitialized 0, 'kotlin/jvm/internal/FunctionReference' }
Bytecode:
0x0000000: bb00 1059 2bb8 0042 2bb6 0020 2bb6 0021
0x0000010: 2bb6 001f b700 38b0
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at kotlin.jvm.internal.Reflection.<clinit>(Reflection.java:32)
at kotlin.io.ConsoleKt.<clinit>(Console.kt)
at com.jsonlogic.RunnerKt.readInput(Runner.kt:40)
at com.jsonlogic.RunnerKt.main(Runner.kt:14)
snowe
07/10/2017, 8:02 PMjava.util.List<? extends Blah>
type into a kotlin method that accepts a type of kotlins kotlin.collections.List<out Blah>
?dszopa
07/21/2017, 2:49 AMjavaType!
indicating it could be nullable or non nullable, where as the kotlin type shows up as `kotlinType?`indicating nullablemp911de
07/25/2017, 1:15 PMwouterdoeland
08/07/2017, 8:58 AMgrandstaish
08/26/2017, 2:15 AMrawType.kotlin.primaryConstructor
returns null
. What sorts of things do I need to keep in order for kotlin-reflect to be able to find the primary constructor of a class at runtime? Just keeping the @Metadata
annotation methods (as the library suggests) is not enough. Keeping all kotlin classes (-keep class kotlin.** { *; }
) does work, but I'd rather just keep what I need.janvladimirmostert
09/09/2017, 10:04 AMjava.lang.IllegalArgumentException: Callable expects 4 arguments, but 3 were provided.
This is the place where I'm doing the call:
annotation.listeners.forEach { listener: KClass<*> ->
listener.functions.forEach { function: KFunction<*> ->
if (function.name == "before") {
function.call(annotation.action, request, response)
}
}
}
And this is the method on the interface that's being called:
interface ControllerListener {
fun before(action: String, request: RestRequest, response: RestResponse)
fun after(action: String, request: RestRequest, response: RestResponse)
}
What should the fourth paramater be?snowe
09/23/2017, 9:57 PMMarc Knaup
10/31/2017, 12:09 PM.javaClass
doesn’t use out
projection 😮yoavst
11/10/2017, 10:20 AMboundReference::fieldName
miha-x64
11/19/2017, 11:15 AMsomeInlineFunc<A<X>, A<Y>, B<X>>()
, is there a way to say that first two type arguments are different?
(Okay, I've resolved my task without it, now it's just a proof-of-concept question.)snowe
11/20/2017, 8:28 PMsdeleuze
11/23/2017, 1:20 PMnatpryce
11/24/2017, 3:10 PMas?
operator.diesieben07
12/08/2017, 5:04 PMgetDeclaringClass
from Java. kotlin.jvm.internal.CallableReference
has getOwner
, but that is internal API and only available for references...mp911de
01/17/2018, 4:21 PMCLASS
, FILE_FACADE
, …) of a Kotlin class?beholder
01/18/2018, 5:35 PMClass.getEnclosingClass()
for KClass
?benny.huo
01/18/2018, 10:43 PMsuperTypes
to retrieve superTypes of RepoListFragment
while its superClass CommonListFragment
was mapped to com.bennyhuo.github.view.common.b
.
The runtime crash:
java.lang.IllegalStateException: Incomplete hierarchy for class RepoListFragment, unresolved classes [com.bennyhuo.github.view.common.CommonListFragment]
at kotlin.reflect.jvm.internal.components.RuntimeErrorReporter.reportIncompleteHierarchy(RuntimeErrorReporter.kt:26)
at kotlin.reflect.jvm.internal.impl.serialization.deserialization.descriptors.DeserializedClassDescriptor$DeserializedClassTypeConstructor.computeSupertypes(DeserializedClassDescriptor.kt:187)
After hours of searching I found that kotlin-reflect get the type infomation from the annotation Metadata
while the value of it may not be processed by proguard.
@Metadata(
mv = {1, 1, 7},
bv = {1, 0, 2},
k = 1,
d1 = {"..."},
d2 = {"Lcom/bennyhuo/github/view/fragments/subfragments/RepoListFragment;", "Lcom/bennyhuo/github/view/common/CommonListFragment;", "Lcom/bennyhuo/github/network/entities/Repository;", "Lcom/bennyhuo/github/presenter/RepoListPresenter;", "()V", "adapter", "Lcom/bennyhuo/github/view/fragments/RepoListAdapter;", "getAdapter", "()Lcom/bennyhuo/github/view/fragments/RepoListAdapter;", "production sources for module app"}
)
Any suggestions or workaround?😳albertgao
01/23/2018, 4:24 AMparam.type === nz.salect.objJSON.JVMBranchTest.MenuObject?
where param:KParameter
. But when I tried to get the class definition from param.type
via param.type::class
. Instead of getting the above MenuObject
, I get a class kotlin.reflect.jvm.internal.KTypeImpl
. How to get my own class , I mean, a KClass
? Thanks 🙂albertgao
01/23/2018, 5:26 AMList<*>
is a kotlin official class or my own class, I currently check its name: paramName.substring(24).removeSuffix(">")
, so "kotlin.collections.List<nz.salect.objJSON.Lesson>"
will become "nz.salect.objJSON.Lesson"
, and then I can verify whether it startsFrom("kotlin")
or not. What’s a better way to do this?snowe
01/27/2018, 12:05 AMgroostav
02/02/2018, 1:29 AMKProperty1
instance, is it possible to know if its declaration is backed by a delegate?groostav
02/02/2018, 1:29 AMKProperty1
instance, is it possible to know if its declaration is backed by a delegate?diesieben07
02/02/2018, 8:23 AMgetDelegate
function on KProperty1
.