Catch NoSuchFieldException

This commit is contained in:
Michael Bogdanov
2015-09-04 15:47:54 +03:00
parent 606b39698c
commit 974095313c
@@ -97,13 +97,18 @@ public val KType.javaType: Type
public val Class<*>.kotlinPackage: KPackage?
get() = if (getSimpleName().endsWith("Package") &&
getAnnotation(javaClass<kotlin.jvm.internal.KotlinPackage>()) != null) {
val field = this.getField(JvmAbi.KOTLIN_MODULE_FIELD_NAME)
if (field != null) {
KPackageImpl(this, field.get(null) as String)
} else {
try {
val field = this.getField(JvmAbi.KOTLIN_MODULE_FIELD_NAME)
if (field != null) {
KPackageImpl(this, field.get(null) as String)
}
else {
null
}
}
catch(e: NoSuchFieldException) {
null
}
} else null