论文标题
Reflekt:Kotlin中用于编译时间反射的库
Reflekt: a Library for Compile-Time Reflection in Kotlin
论文作者
论文摘要
Kotlin中的反思是在运行时执行过程中内省程序行为的有力机制。但是,在涉及反思的各种实际任务中,在某些情况下,运行时间方法的表现不佳成为一个重要的劣势。这个问题在无服务器应用程序的流行框架中表现出来,因为应用程序启动的速度越快,其云基础架构成本就越少。在本文中,我们提出了Reflekt-编译时间反射库,该库允许在类中执行搜索,对象表达式(在Kotlin中将其实现为Singleton类),以及基于给定的搜索查询中的Kotlin代码中的功能。与现有的运行时反射方法相比,它具有方便的DSL和更好的性能。我们的实验表明,用Reflekt在使用Kotless创建的无服务器应用程序中替换运行时反射调用,从而在这些应用程序的启动时间内显着提高了性能。
Reflection in Kotlin is a powerful mechanism to introspect program behavior during its execution at run-time. However, among the variety of practical tasks involving reflection, there are scenarios when the poor performance of run-time approaches becomes a significant disadvantage. This problem manifests itself in Kotless, a popular framework for developing serverless applications, because the faster the applications launch, the less their cloud infrastructure costs. In this paper, we present Reflekt - a compile-time reflection library which allows to perform the search among classes, object expressions (which in Kotlin are implemented as singleton classes), and functions in Kotlin code based on the given search query. It comes with a convenient DSL and better performance comparing to the existing run-time reflection approaches. Our experiments show that replacing run-time reflection calls with Reflekt in serverless applications created with Kotless resulted in a significant performance boost in start-up time of these applications.