We just upgraded our codebase to Guava 20 and started getting this compiler error:
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] cannot access com.google.errorprone.annotations.CanIgnoreReturnValue
class file for com.google.errorprone.annotations.CanIgnoreReturnValue not found
[INFO] 1 error
[INFO] -------------------------------------------------------------
It seems similar to #2721 except that it affects both Guava 20 and 21 and also seems much more serious since it's an actual compile error and not a warning. After investigating further, the issue seems to be when using (any) annotation processing as well as ForwardingExecutorService
(which was annotated with @CanIgnoreReturnValue
as part of Guava 20). My uninformed guess is that javac wants to walk the type hierarchy so it can execute the right annotation processors, so when you have a class that extends ForwardingExecutorService
it will try to read the annotations and fail when it gets to @CanIgnoreReturnValue
.
I pushed a very simple example here, you can clone it and run mvn compile
to reproduce the issue. The project just has a class that extends ForwardingExecutorService
:
public class MyExecutorService extends ForwardingExecutorService { protected ExecutorService delegate() { return null; } }
and a META-INF/services/javax.annotation.processing.Processor
file to activate javac's annotation processing. Note that the service file points to a non-existent annotation processor and the build still fails with the CanIgnoreReturnValue
error. This seems to suggest that the failure is happening while javac is setting up for annotation processing, rather than while the annotation processor is executing (eg, the failure is not related to the implementation of the annotation processor nor is there a way for an annotation processor to catch and ignore these errors).
I see that transitive dependencies have been added as part of Guava 22, which seems unfortunate but probably better than the alternative (especially in light of this issue). The other "fix" that comes to mind is to remove the class-level @CanIgnoreReturnValue
annotation from ForwardingExecutorService
and instead annotate the individual methods (in my testing this didn't cause the same compile error, but might cause the warnings that #2721 was referring to). Would it be possible to get a new release of Guava 20 and 21 with one of these (or some other) fix?
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.3