Skip to content
Lightweight library allowing to introspect basic stuff about Kotlin symbols
Branch: master
Clone or download
Latest commit 47bfb95 Feb 19, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Add Apache 2.0 license, update copyright in sources Dec 12, 2017
.gitignore
CHANGELOG.md Untie version from the Kotlin version, add changelog Dec 12, 2017
LICENSE
ReadMe.md
copy.sh Update code to the new Metadata annotation Feb 4, 2016
pom.xml Fix platform encoding warning Dec 12, 2017
reflect-lite.pro Make proguard keep annotations in the bytecode (#2) Oct 13, 2015

ReadMe.md

Kotlin Kotlin Slack

kotlinx.reflect.lite

This library provides an API to introspect Kotlin symbols at runtime. Its main feature is the small size which makes it possible to use it on memory-constrained devices.

Download

Maven

Add jcenter repository (if you don't have it yet)

<repository>
    <snapshots>
        <enabled>false</enabled>
    </snapshots>
    <id>central</id>
    <name>bintray</name>
    <url>https://jcenter.bintray.com</url>
</repository>

Add a dependency:

<dependency>
    <groupId>org.jetbrains.kotlinx</groupId>
    <artifactId>kotlinx.reflect.lite</artifactId>
    <version>1.0.0</version>
</dependency>

Gradle

jcenter is configured by default in gradle however you may need to include it in some cases

repositories {
    jcenter()
}

Add a dependency:

compile 'org.jetbrains.kotlinx:kotlinx.reflect.lite:1.0.0'

FAQ

Why not just use Java reflection instead?

Java reflection cannot figure out Kotlin-specific features of the introspected program. For example, nullability of Kotlin types is erased in JVM bytecode.

Also parameter names were not supported in Java reflection until Java 8.

Why not just use Kotlin reflection instead?

While Kotlin has its own reflection library, its size is currently above 2Mb which may be unacceptable in some circumstances, for example on Android.

The size of the minimized version of this library is about 100Kb plus the dependency on protobuf-java.

What is supported?

Currently the only supported features are names of parameters and nullability of their types.

You can’t perform that action at this time.