Fixed loading integral constants from compiled classes.
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
package constants
|
||||
|
||||
import java.lang.annotation.Retention
|
||||
import java.lang.annotation.RetentionPolicy
|
||||
|
||||
public val b: Byte = 100
|
||||
public val s: Short = 20000
|
||||
public val i: Int = 2000000
|
||||
public val l: Long = 2000000000000L
|
||||
public val f: Float = 3.14f
|
||||
public val d: Double = 3.14
|
||||
public val bb: Boolean = true
|
||||
public val c: Char = '\u03c0' // pi symbol
|
||||
|
||||
public val str: String = ":)"
|
||||
|
||||
[Retention(RetentionPolicy.RUNTIME)]
|
||||
public annotation class AnnotationClass(public val value: String)
|
||||
@@ -0,0 +1,12 @@
|
||||
import constants.*
|
||||
|
||||
AnnotationClass("$b $s $i $l $f $d $bb $c $str")
|
||||
class DummyClass()
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val klass = javaClass<DummyClass>()!!
|
||||
val annotationClass = javaClass<AnnotationClass>()
|
||||
val annotation = klass.getAnnotation(annotationClass)!!
|
||||
val value = annotation.value
|
||||
require(value == "100 20000 2000000 2000000000000 3.14 3.14 true \u03c0 :)", "Annotation value: $value")
|
||||
}
|
||||
Reference in New Issue
Block a user