motif icon indicating copy to clipboard operation
motif copied to clipboard

Missing import can cause vague crash

Open kurtisnelson opened this issue 6 years ago • 2 comments

If an import is missing, the annotation processor can crash with a useless error.

+--------------------------------------------------------------------------------------------------+
|                                                                                                  |
| The annotation processor motif.compiler.Processor has crashed.                                   |
|                                                                                                  |
| This is likely a bug in the annotation processor itself, though there may be changes you can     |
| make to your code to work around it. Examine the exception stack trace below and consult the     |
| annotation processor's troubleshooting guide.                                                    |
|                                                                                                  |
| javax.lang.model.element.UnknownElementException: Unknown element:                               |
|  at javax.lang.model.util.AbstractElementVisitor6.visitUnknown(AbstractElementVisitor6.java:129) |
|  at com.sun.tools.javac.code.Symtab$6.accept(Symtab.java:410)                                    |
|  at motif.compiler.codegen.NameVisitor.visitDeclared(Names.kt:57)                                |
|  at motif.compiler.codegen.NameVisitor.visitError(Names.kt:82)                                   |
|  at motif.compiler.codegen.NameVisitor.visitError(Names.kt:39)                                   |
|  at com.sun.tools.javac.code.Type$ErrorType.accept(Type.java:2383)                               |
|  at javax.lang.model.util.AbstractTypeVisitor6.visit(AbstractTypeVisitor6.java:105)              |
|  at motif.compiler.codegen.Names$Companion.safeName(Names.kt:30)                                 |
|  at motif.compiler.codegen.JavaPoetUtil$NameScope.name(JavaPoetUtil.kt:166)                      |
|  at motif.compiler.codegen.JavaPoetUtil$NameScope.methodSpecBuilder(JavaPoetUtil.kt:150)         |
|  at motif.compiler.codegen.JavaPoetUtil$methodSpecBuilders$1.invoke(JavaPoetUtil.kt:128)         |
|  at motif.compiler.codegen.JavaPoetUtil$methodSpecBuilders$1.invoke(JavaPoetUtil.kt:39)          |
|  at motif.compiler.codegen.JavaPoetUtil$DefaultImpls.nameScope(JavaPoetUtil.kt:142)              |
|  at motif.compiler.codegen.CodegenCache.nameScope(CodegenCache.kt:32)                            |
|  at motif.compiler.codegen.JavaPoetUtil$DefaultImpls.methodSpecBuilders(JavaPoetUtil.kt:127)     |
|  at motif.compiler.codegen.CodegenCache.methodSpecBuilders(CodegenCache.kt:32)                   |
|  at motif.compiler.codegen.ScopeImplFactory.dependencies(ScopeImplFactory.kt:74)                 |
|  at motif.compiler.codegen.ScopeImplFactory.create(ScopeImplFactory.kt:48)                       |
|  at motif.compiler.codegen.Generator.generate(Generator.kt:34)                                   |
|  at motif.compiler.Processor.process(Processor.kt:63)                                            |
|  at motif.compiler.Processor.process(Processor.kt:50)                                            |
|                                                                                                  |
+--------------------------------------------------------------------------------------------------+

    When running javac
    When running <javac_jar>.

kurtisnelson avatar Jan 09 '19 01:01 kurtisnelson

Before I forget: The specific issue that caused this was a missing import for an @Inject-ed constructor parameter type.

Leland-Takamine avatar Jan 09 '19 01:01 Leland-Takamine

I've also hit the same issue with a missing (deleted) type that was constructor injected as parameter for another type.

aitorvs avatar Oct 01 '19 05:10 aitorvs