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

Update of different dependency: Error "package javax.annotation.processing is not visible" #4321

Closed
infeo opened this issue Jun 4, 2024 · 4 comments

Comments

@infeo
Copy link

infeo commented Jun 4, 2024

In our project cryptomator/cryptofs, we use Dagger and also Google Guava.

When we update Google Guava from 33.0.0-jre to 33.1.0-jre, compilation fails with the error "package javax.annotation.processing is not visible". Looking into the error, only Dagger generated classes are affected, because by this external update, suddenly Dagger adds to every generated class the following annotation:

@Generated(
    value = "dagger.internal.codegen.ComponentProcessor",
    comments = "https://dagger.dev"
)

Prior to the dependency update, only the @DaggerGenerated annotation was present. I found #1339, but the project has already language level 17 as release target.

The fix inside an affected project is simple(add java.compiler to the module-info.java), but I'm wondering, how the change of an external dependency leads to a different generated source of dagger.

@Chang-Eric
Copy link
Member

Dagger tries to find if the Generated annotation is on the class path and then outputs that if it is there, so there is probably some change there between the upgrading the versions that made it visible to the us?

https://github.com/google/dagger/blob/master/java/dagger/internal/codegen/base/SourceFileGenerator.java#L81 which uses https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:room/room-compiler-processing/src/main/java/androidx/room/compiler/processing/ksp/KspProcessingEnv.kt;l=173;drc=067ed409b9bc2dcc59b93c8e9ab8d092beeff3a5 (That's the KSP version. There's something similar for javac, but it is easier to see in the KSP version).

The fix is easy (add java.compiler to the module-info.java)

I'm not really that familiar with how the module-info.java stuff works, but is that a fix needed in Dagger?

@infeo
Copy link
Author

infeo commented Jun 7, 2024

Dagger tries to find if the Generated annotation is on the class path and then outputs that if it is there

Does that mean the generated annotation was not present on the classpath before and now it is? I searched the web a little more and it might be related to the fact, that dagger uses https://github.com/google/auto, which uses guava in turn. By updateing to the latest guava, there might have a been difference classpath order. Also found https://stackoverflow.com/a/53187201, which explains a little the annotation search and #1449 which might be related.

I'm not really that familiar with how the module-info.java stuff works, but is that a fix needed in Dagger?

My bad, this is not a fix in Dagger, this fix applies to an affected project. 😅 I updated the my opening comment.

@Chang-Eric
Copy link
Member

Does that mean the generated annotation was not present on the classpath before and now it is?

Yup I think so.

My bad, this is not a fix in Dagger, this fix applies to an affected project. 😅 I updated the my opening comment.

Ah cool, thanks! Let me know if there's anything needed then in Dagger, otherwise I think this issue could probably be closed?

@infeo
Copy link
Author

infeo commented Jun 18, 2024

otherwise I think this issue could probably be closed?

I think so too. 🙃

infeo added a commit to cryptomator/cryptomator that referenced this issue Aug 13, 2024
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

2 participants