Skip to content

Commit

Permalink
Let annotation processor crash in case that Map Implementation is not…
Browse files Browse the repository at this point in the history
… compiled yet.
  • Loading branch information
sockeqwe committed Oct 31, 2018
1 parent d2b8bf9 commit 16d244b
Showing 1 changed file with 8 additions and 7 deletions.
Expand Up @@ -108,13 +108,14 @@ class TypeAdapterCodeGenerator(private val filer: Filer, private val elementUtil

val targetClassToParseInto = getClassToParseInto(annotatedClass)

val mapImplClass: Class<*> = mapImpl?.isNullOrEmpty()?.not()?.let {
try {
Class.forName(mapImpl)
} catch (classNotFound: ClassNotFoundException) {
HashMap::class.java
}
} ?: HashMap::class.java
val mapImplClass: Class<*> = if (mapImpl != null) {
// TODO improve that one.
// What if class is not compiled yet so that Class.forName() throws not found exception?
// Now compiler will crash.
Class.forName(mapImpl)
} else {
HashMap::class.java
}

if (annotatedClass.hasAttributes()) {
val attributeBinderMapField = ParameterizedTypeName.get(ClassName.get(java.util.Map::class.java),
Expand Down

0 comments on commit 16d244b

Please sign in to comment.