Hey , i'm writing a kotlin compiler plugin that wi...
# compiler
a
Hey , i'm writing a kotlin compiler plugin that will generate code that use some android classes how can i generate code that use the android classes like View.java ?
f
What type of code do you want to generate? Java Bytecode, Java or Kotlin?
a
i want to generate byte code in fact i m working on a methode call logging project that use Timber to log the name and parametre of the function
f
I don't know much about byte code generation, but that reminds me of this plugin: https://github.com/kevinmost/debuglog

https://www.youtube.com/watch?v=w-GMlaziIyo&feature=youtu.be&t=617

a
Yeah i've already saw this talk and the github repo but he is generating System.ou.print() logs not using android dependencies
g
Maybe just add android.jar to dependencies, so you can compile it
a
mm yeah i saw that the android extension use that but where can i get the android jar ?
s
You don't really need any jars to compile View references. Depending on which level you are generating on (IR or actual bytecode) you can use different mechanics, usually referring to classes by FqName and such. See
AbstractAndroidExtensionsExpressionCodegenExtension#generateClearFindViewByIdCacheFunctionCall
as an example.
a
Okey I got you so i can use the FqName to referre to a class without adding it to the dependencies , but the class need to be there when the compiler is used to compile android source , does it work with external librairies ?
s
it doesn't really care about android source, unless you want to use Kotlin descriptors and other info. Otherwise, you can just add bytecode
invokevirtual
of View methods, it will check the class availability in runtime only.
👍 1
a
Okey great thanks for the info 👌
g
You can get android.jar from Android SDK
😮 1
1