From 974095313cae2184999948fb60f0d445642812f9 Mon Sep 17 00:00:00 2001 From: Michael Bogdanov Date: Fri, 4 Sep 2015 15:47:54 +0300 Subject: [PATCH] Catch NoSuchFieldException --- .../src/kotlin/reflect/jvm/mapping.kt | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/mapping.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/mapping.kt index 9e518222f5b..d6251aa475c 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/mapping.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/mapping.kt @@ -97,13 +97,18 @@ public val KType.javaType: Type public val Class<*>.kotlinPackage: KPackage? get() = if (getSimpleName().endsWith("Package") && getAnnotation(javaClass()) != 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