RuneMate / Issues

Client and API Issue tracking. See README for more information.
8 stars 0 forks source link

Kotlin reflection not implemented (kotlin-reflect.jar required) #35

Closed simwij closed 5 years ago

simwij commented 5 years ago

Describe the bug Could not run my first bot from the bot store because of missing kotlin dependency. Reflection was not supported. This code snippet specifically:

// Reflection 'this::'
//... inside some class
logger.info("${this::class.simpleName} a message from this class I'm in right now")

Affected game modes: Only tested on OSRS, but should also affect RS3.

RuneMate version: 2.95.17

To Reproduce Steps to reproduce the behaviour:

  1. Use my broken bot (revision 3) OR
  2. Paste the code snippet above in any bot
  3. Make sure to run the bot from the bot store or with equivalent dependencies
  4. Exception is thrown when code reached

Please include the code used to produce this bug.

// Reflection 'this::'
//... inside some class
logger.info("${this::class.simpleName} a message from this class I'm in right now")

Expected behaviour The message should be logged.

Screenshots None.

Additional context Trace:

kotlin.jvm.KotlinReflectionNotSupportedError: Kotlin reflection implementation is not found at runtime. Make sure you have kotlin-reflect.jar in the classpath
    at kotlin.jvm.internal.ClassReference.error(ClassReference.kt:79)
    at kotlin.jvm.internal.ClassReference.getSimpleName(ClassReference.kt:12)
    at com.simpe.nestcrusher.NestCrusherBot.true(rm.entrypoint:15)
    at com.simpe.nestcrusher.NestCrusherBot.void(rm.entrypoint:14)
    at robot.IIiiIIiIIi.execute(a:168)
    at com.runemate.game.api.script.framework.tree.TreeBot.onLoop(TreeBot.java:58)
    at com.runemate.game.api.script.framework.LoopingBot.run(LoopingBot.java:59)
    at com.runemate.game.api.script.framework.AbstractBot.start(AbstractBot.java:301)
    at nul.IIIIiIiiIiIIi.run(BotThread.java:28)
EJ-K commented 5 years ago

Use the Java class's getSimpleName() instead of the KClass's.

ccarpenter04 commented 5 years ago

This will be supported properly.

simwij commented 5 years ago

Use the Java class's getSimpleName() instead of the KClass's.

You are right. This works in place of the kotlin class.

ccarpenter04 commented 5 years ago

It should be rejected or fail to compile if it fails at runtime so either we should make it be rejected or just support it properly to prevent any confusion.

EJ-K commented 5 years ago

This will be supported properly.

You sure we want to support Kotlin reflection? Means adding some checks to the botstore watchdog.

ccarpenter04 commented 5 years ago

I'm aware that we'll have to blacklist certain additional calls. Would you mind starting a list?

ccarpenter04 commented 5 years ago

This should now be functional, could someone else please verify that.

simwij commented 5 years ago

Yep, it works.