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

Code generation in Eclipse is broken. #912

Closed
AndreasMager opened this issue Oct 24, 2017 · 15 comments
Closed

Code generation in Eclipse is broken. #912

AndreasMager opened this issue Oct 24, 2017 · 15 comments

Comments

@AndreasMager
Copy link

AndreasMager commented Oct 24, 2017

Code generation doesn't complete. The Dagger_XXX Files are missing

Dagger Version 2.12

Eclipse Version: Oxygen.1 Release (4.7.1)

Log:

org.eclipse.jdt.apt.pluggable.core
Error
Tue Oct 24 17:18:29 CEST 2017
Exception thrown by Java annotation processor dagger.internal.codegen.ComponentProcessor@79160e13

java.lang.Exception: java.util.NoSuchElementException: No value present
	at org.eclipse.jdt.internal.compiler.apt.dispatch.RoundDispatcher.handleProcessor(RoundDispatcher.java:169)
	at org.eclipse.jdt.internal.compiler.apt.dispatch.RoundDispatcher.round(RoundDispatcher.java:121)
	at org.eclipse.jdt.internal.compiler.apt.dispatch.BaseAnnotationProcessorManager.processAnnotations(BaseAnnotationProcessorManager.java:159)
	at org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeAnnotationProcessorManager.processAnnotations(IdeAnnotationProcessorManager.java:135)
	at org.eclipse.jdt.internal.compiler.Compiler.processAnnotations(Compiler.java:915)
	at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:437)
	at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:417)
	at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:368)
	at org.eclipse.jdt.internal.core.builder.BatchImageBuilder.compile(BatchImageBuilder.java:187)
	at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:305)
	at org.eclipse.jdt.internal.core.builder.BatchImageBuilder.build(BatchImageBuilder.java:61)
	at org.eclipse.jdt.internal.core.builder.JavaBuilder.buildAll(JavaBuilder.java:256)
	at org.eclipse.jdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:175)
	at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:735)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:206)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:246)
	at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:301)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:304)
	at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:360)
	at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:383)
	at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:142)
	at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:232)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:56)
Caused by: java.util.NoSuchElementException: No value present
	at java.util.Optional.get(Optional.java:135)
	at dagger.internal.codegen.SubcomponentDeclaration$Factory.forModule(SubcomponentDeclaration.java:65)
	at dagger.internal.codegen.ModuleDescriptor$Factory.create(ModuleDescriptor.java:197)
	at dagger.internal.codegen.ComponentDescriptor$Factory.create(ComponentDescriptor.java:503)
	at dagger.internal.codegen.ComponentDescriptor$Factory.create(ComponentDescriptor.java:554)
	at dagger.internal.codegen.ComponentDescriptor$Factory.forComponent(ComponentDescriptor.java:474)
	at dagger.internal.codegen.ComponentProcessingStep.process(ComponentProcessingStep.java:132)
	at dagger.internal.codegen.ComponentProcessingStep.process(ComponentProcessingStep.java:47)
	at dagger.shaded.auto.common.BasicAnnotationProcessor.process(BasicAnnotationProcessor.java:329)
	at dagger.shaded.auto.common.BasicAnnotationProcessor.process(BasicAnnotationProcessor.java:182)
	at org.eclipse.jdt.internal.compiler.apt.dispatch.RoundDispatcher.handleProcessor(RoundDispatcher.java:139)
	... 24 more
@AndreasMager AndreasMager changed the title Eclipse log some Errors Code generation in Eclipse is broken. Nov 2, 2017
@ronshapiro
Copy link

I recommend trying to clean your build and recompile. This appears to me as an eclipse bug.

@AndreasMager
Copy link
Author

AndreasMager commented Nov 15, 2017

Clean & rebuild doesn't work. Since i have added Subcomponents to the project, the eclipse buildsystem is broken.
The gradle build still works

I have tried to hack/fix the codegen part. My changes have removed the build errors but lead to new problems .
AndreasMager@26698b6

@ronshapiro
Copy link

Then I recommend filing a bug with eclipse.

@AndreasMager
Copy link
Author

The stacktrace above shows the error is raised in dagger:

Caused by: java.util.NoSuchElementException: No value present
	at java.util.Optional.get(Optional.java:135)
	at dagger.internal.codegen.SubcomponentDeclaration$Factory.forModule(SubcomponentDeclaration.java:65)

There is a missing isPresent check.

@brychcy
Copy link

brychcy commented Nov 17, 2017

Is there a sample project?

@foal
Copy link

foal commented Nov 17, 2017

Just for reference: https://bugs.eclipse.org/bugs/show_bug.cgi?id=526288

@brychcy
Copy link

brychcy commented Nov 17, 2017

Somebody asked in that eclipse bug about this bug, but it is actually unrelated.

@foal
Copy link

foal commented Nov 17, 2017

Somebody it's me :)

I have a very simple project (forked from https://github.com/ibaca/gwt-dagger2-coffee) that use the Subcomponent to enable GWT code splitting. You can see it on https://bitbucket.org/foal/gwt-dagger2-coffee

@foal
Copy link

foal commented Nov 17, 2017

The error reproduced on commit https://bitbucket.org/foal/gwt-dagger2-coffee/commits/5b5505303ece4b87b1e39802a76907aa79e7b7d5

If I will extract the interface DripCoffeeComponent from 'CoffeeDi' class to own file the bug is gone.

@brychcy
Copy link

brychcy commented Nov 17, 2017

I thought about it - it could actually be triggered by 526288, in which case it will be fixed in Eclipse 4.7.2.
I can try it on the weekend.
If you have time, you can try a recent build like http://download.eclipse.org/eclipse/downloads/drops4/M20171115-1700/

@AndreasMager
Copy link
Author

Here is my sample project:
https://github.com/AndreasMager/eclipse-dagger-test

@AndreasMager
Copy link
Author

AndreasMager commented Nov 17, 2017

Ok my test project caused not the same error as above. I reproduced it wit my 3 commit.
I have tested the eclipse download. It solves commit 1 and 2 in my project.
The 3 commit is still broken. In that one i changed the folder layout to a multi project setup.

@brychcy
Copy link

brychcy commented Nov 19, 2017

Thanks, based on https://github.com/AndreasMager/eclipse-dagger-test if found another bug in eclipse: https://bugs.eclipse.org/bugs/show_bug.cgi?id=527462.
Unfortunately, this alone doesn't allow to compile your test project, their is another bug either in dagger 2 or eclipse.
BTW: I tried to set up dagger 2 as source project in eclipse to allow efficient debugging, but failed (the bazel eclipse plugin doesn't allow importing it ( even the master version) and it has too many dependencies to manually configure the classpath)

@brychcy
Copy link

brychcy commented Nov 20, 2017

I've been able to track down the other issue, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=527530

@facboy
Copy link

facboy commented Feb 27, 2018

I can't claim to be an expert on this but I am seeing this error on one of our projects where some of the modules are themselves generated. Ultimately the root cause appears to be that eclipse is unable to resolve the module type when it first encounters it, and so the moduleElement in question is an ErrorTypeElement. Calling getAnnotationMirrors() on this returns an empty list, so ultimately the @Module annotation is not found. Presumably in the jdk compiler throws a TypeNotFoundException in this case (if not here, somewhere in the code path).

I am unsure whether this is a bug in eclipse or whether Dagger ought to check whether the type element is in fact correctly resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants