Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Motif should handle presence of ErrorType gracefully #51

Open
andreasnomikos opened this issue Mar 14, 2019 · 3 comments
Open

Motif should handle presence of ErrorType gracefully #51

andreasnomikos opened this issue Mar 14, 2019 · 3 comments
Labels
enhancement New feature or request

Comments

@andreasnomikos
Copy link

When running motif in incremental compilation build setting the motif compiler tends to crash out frequently whenever it encounters an ErrorType.
Instead motif should defer parsing structures that contain error types and let javac report them during its normal compilation.

0.0.13:

Repro steps or stacktrace:
+--------------------------------------------------------------------------------------------------+
This was from having an ErrorType as a parameter to a basic factory method.
Have encountered other in other spots of the compiler when an error type is the return type of a factory method et.al.

| |
| 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:93) |
| at motif.compiler.codegen.ScopeImplFactory.create(ScopeImplFactory.kt:50) |
| 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>.
When building rule //apps/presidio/jump/module/identity/info:src_release.
@andreasnomikos
Copy link
Author

This should also help increase the robustness of motif compiler when running with other APs that generate new Types. e.g. providing an annotation processor generated type through DI

@Leland-Takamine
Copy link
Collaborator

This should also help increase the robustness of motif compiler when running with other APs that generate new Types. e.g. providing an annotation processor generated type through DI

Agree that we should handle error types better. The annotation processing order should already be handled by BasicAnnotationProcess (with some caveats).

@andreasnomikos
Copy link
Author

One more case of an exception with ErrorTypes in 0.1.0

class Interactor {

Interactor(ErrorType badImport) 
}

@motif.Scope
interface Scope {
  
  @motif.Objects
  abstract class Objects {
    abstract Interactor interactor();
  }
}

Fails with

| java.lang.IllegalArgumentException: not a valid name: |
| at com.squareup.javapoet.Util.checkArgument(Util.java:64) |
| at com.squareup.javapoet.MethodSpec$Builder.(MethodSpec.java:284) |
| at com.squareup.javapoet.MethodSpec$Builder.(MethodSpec.java:268) |
| at com.squareup.javapoet.MethodSpec.methodBuilder(MethodSpec.java:172) |
| at motif.compiler.UtilKt.methodSpec(Util.kt:59) |
| at motif.compiler.Dependencies$Companion.create(Dependencies.kt:67) |
| at motif.compiler.ScopeImplsFactory$getDependencies$1.apply(ScopeImpl.kt:269) |
| at motif.compiler.ScopeImplsFactory$getDependencies$1.apply(ScopeImpl.kt:236) |
| at java.util.HashMap.computeIfAbsent(HashMap.java:1127) |
| at motif.compiler.ScopeImplsFactory.getDependencies(ScopeImpl.kt:267) |
| at motif.compiler.ScopeImplsFactory.getScopeImpls(ScopeImpl.kt:261) |
| at motif.compiler.ScopeImplsFactory$Companion.create(ScopeImpl.kt:284) |
| at motif.compiler.ScopeImpl$Companion.create(ScopeImpl.kt:40) |
| at motif.compiler.Processor$Step.process(Processor.kt:65) |
| at com.google.auto.common.BasicAnnotationProcessor.process(BasicAnnotationProcessor.java:330) |
| at com.google.auto.common.BasicAnnotationProcessor.process(BasicAnnotationProcessor.java:181) |
| |
+------------------------------------------------------------------------------------------------+

When running javac
When running <javac_jar>.

@Leland-Takamine Leland-Takamine added the enhancement New feature or request label Aug 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants