-
Notifications
You must be signed in to change notification settings - Fork 10.9k
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
Many warning messages related to errorprone "CompatibleWith" #2721
Comments
The reason is that we don't make the Error Prone annotations available to our users at compile time. We could maybe change that, but our understanding has been that it shouldn't be necessary. Do you know if you're using any Maven plugins that might be plugging into the compiler (annotation processors, mainly)? |
These warnings are happening even in some pretty simple packages where there are no exotic maven plugins. It does not happen on all of my modules that use Guava. But I haven't narrowed-down which Guava class is involved. The warnings happen during the "default-compile" step from maven-compiler-plugin. I've tried version 3.3 and 3.6 of that plugin. The warnings appear even if I set |
Ok. So this is related to annotation processors of some basic sort. My standard build involves this: <build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerArgs>
<arg>-Xlint:all</arg>
<arg>-Xlint:-serial</arg>
</compilerArgs>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
</plugins>
</build> The warnings are shown only when I include Then 9 identical warnings appear if my java code contains one single line like this: So, I don't know if there is a bug in maven compiler plugin, or in Guava's Again, not a bug in the program operation, just an annoying set of warning messages. |
We ran into this attempting to upgrade the We also don't do anything super fancy with Maven plugins, but we do attempt to set "warnings as errors" everywhere. That said, despite being logged at
|
Thanks. I tried pulling the |
No, sorry, an earlier version of this comment incorrectly stated the build failed. The actual problem is that the javac output all gets logged at the maximum error level -- so the |
I am also seeing this, on a standard
Because we want to use |
@PhilippWendler thanks for trying javac. Which JDK version is it? I have found that I can eliminate the warning message in a Maven build by using this flag for the |
I tested with javac 1.8.0_111 from OpenJDK. |
Running If anyone can point me to a repository and a command that I can use to reproduce this, that would be a big help. There's definitely something wrong, but I need to figure out where to point the finger (which might be at us -- I'm not just not sure yet). |
In the meantime, as a workaround, you can probably add an explicit dependency on:
|
^ And if you declare that dependency |
You should be able to reproduce the problem in branch The problem is reproducible with this branch on AppVeyor (log) and Travis (log). Btw, we are even using error-prone already (though I disabled it in that branch for easier debugging) and want to upgrade to 2.0.15 at some point anyway, but I think that it would still be good if Guava would not have this problem. The Eclipse Java Compiler builds our project just fine ( |
@cpovirk To reproduce the problem in Maven you must use both You can then reproduce it with a project containing one single java class like this: public class GuavaTest {
private ImmutableTable.Builder table = ImmutableTable.builder();
} |
@PhilippWendler , thanks, I'm now seeing the error. I'll poke around some more. |
And thanks @enwired. I can reproduce with that, too. |
We are also experiencing this issue. The noise makes it hard to want to push Guava 21 forward through all our projects. |
As far as I can tell, this was our fault. Sorry about that. I've fixed it for 22.0. In the meantime, you can try the workaround above. |
Any chance of a 21.1 release? Or is 22.0 coming soon? |
Does the workaround work OK? Knowing that will help us prioritize. @netdpb for an estimate on 22.0. |
Yes, it does work. However I don't think you should expect that everyone will go to github and search this issue. To me personally this definitely seems like a defect large enough to warrant a patch release. It causes everyone who may treat warnings as errors to have to either search for this obscure issue, or to modify their projects in a way that is not reasonable (you should be able to reasonably treat warnings aggressively as external libraries should not be causing compiler warnings). |
I'm using guava 22.0 <groupId>com.google.errorprone</groupId>
<artifactId>error_prone_annotations</artifactId>
<version>2.0.15</version> I have a lot of warnings before and after applying the workaround like this Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
Computing all possible rebind results for 'com.google.gwt.useragent.client.UserAgentAsserter'
Rebinding com.google.gwt.useragent.client.UserAgentAsserter
Checking rule <generate-with class='com.google.web.bindery.requestfactory.gwt.rebind.RequestFactoryGenerator'/>
[WARN] Unknown type 'com.google.web.bindery.requestfactory.shared.RequestFactory' specified in deferred binding rule
Checking rule <generate-with class='com.google.web.bindery.requestfactory.gwt.rebind.RequestFactoryEditorDriverGenerator'/>
[WARN] Unknown type 'com.google.web.bindery.requestfactory.gwt.client.RequestFactoryEditorDriver' specified in deferred binding rule
Checking rule <generate-with class='com.google.gwt.editor.rebind.SimpleBeanEditorDriverGenerator'/>
[WARN] Detected warnings related to 'com.google.gwt.editor.client.SimpleBeanEditorDriver'. Are validation-api-<version>.jar and validation-api-<version>-sources.jar on the classpath?
Specify -logLevel DEBUG to see all errors.
[WARN] Unknown type 'com.google.gwt.editor.client.SimpleBeanEditorDriver' specified in deferred binding rule
Rebinding com.google.gwt.useragent.client.UserAgentAsserter
Checking rule <generate-with class='com.google.web.bindery.requestfactory.gwt.rebind.RequestFactoryGenerator'/>
[WARN] Unknown type 'com.google.web.bindery.requestfactory.shared.RequestFactory' specified in deferred binding rule
Checking rule <generate-with class='com.google.web.bindery.requestfactory.gwt.rebind.RequestFactoryEditorDriverGenerator'/>
[WARN] Unknown type 'com.google.web.bindery.requestfactory.gwt.client.RequestFactoryEditorDriver' specified in deferred binding rule
Computing all possible rebind results for 'com.google.gwt.user.client.DocumentModeAsserter'
Rebinding com.google.gwt.user.client.DocumentModeAsserter
Checking rule <generate-with class='com.google.web.bindery.requestfactory.gwt.rebind.RequestFactoryGenerator'/>
[WARN] Unknown type 'com.google.web.bindery.requestfactory.shared.RequestFactory' specified in deferred binding rule
Checking rule <generate-with class='com.google.web.bindery.requestfactory.gwt.rebind.RequestFactoryEditorDriverGenerator'/>
[WARN] Unknown type 'com.google.web.bindery.requestfactory.gwt.client.RequestFactoryEditorDriver' specified in deferred binding rule
Rebinding com.google.gwt.user.client.DocumentModeAsserter
Checking rule <generate-with class='com.google.web.bindery.requestfactory.gwt.rebind.RequestFactoryGenerator'/>
[WARN] Unknown type 'com.google.web.bindery.requestfactory.shared.RequestFactory' specified in deferred binding rule
Checking rule <generate-with class='com.google.web.bindery.requestfactory.gwt.rebind.RequestFactoryEditorDriverGenerator'/>
[WARN] Unknown type 'com.google.web.bindery.requestfactory.gwt.client.RequestFactoryEditorDriver' specified in deferred binding rule
Computing all possible rebind results for 'com.google.gwt.logging.client.LogConfiguration |
My guess is that those warnings are unrelated -- that they'd be there even if Guava weren't using these annotations at all. I don't know enough about GWT to say what the cause would be, though :( |
The "Cannot find annotation method 'value()' in type 'CompatibleWith'" warning still appears with guava-22.0. Adding error_prone_annotations-2.0.19 to the dependencies helped. |
Update on my comment: When compiling with guava-22.0 and jdk-1.8.0_31 the warning appears without the error_prone_annotations-2.0.19. With jdk-1.8.0_131 no errors, even without the error_prone_annotations jar. |
Such dependencies have caused problems for Guava users, so I'd expect the same here: google/guava#2721 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=198881918
Such dependencies have caused problems for Guava users, so I'd expect the same here: google/guava#2721 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=198881918
…nt, thereby bumping Guava to 25.1 in the POMs I'd missed before. I also: - upgraded to the newest versions of our dependencies, using: mvn versions:use-latest-versions -Dexcludes=org.checkerframework,com.google.gwt,com.google.auto.value,com.google.guava mvn versions:display-dependency-updates # for manual review of dependencies whose versions are set in properties - switched to the currently recommended way of depending on AutoValue (possibly outright necessary after the upgrades, but a good idea anyway) - stopping marking annotations dependencies as <optional>, following our precedent in Guava (google/guava#2721) and even a little already in Truth (CL 198881917) The switch to dependencyManagement also incidentally bumps some jsr305 and Checker Framework versions for some POMs, but that's much less likely to matter. Fixes #473 RELNOTES=Made various dependency fixes and upgrades, including fixing #473. Note that some annotations-only dependencies are now no longer `<provided>`. See google/guava#2721 for details, but in short, feel free to exclude them if that works for your setup. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=204292747
0.42 Made various dependency fixes and upgrades, including fixing #473 and #467. Note that some annotations-only dependencies are now no longer <provided>. See google/guava#2721 for details, but in short, feel free to exclude them if that works for your setup. Fixed NPE in MapSubject.containsExactly (#468). 0.41 Changed most of Truth's failure messages to a multi-line, key-value format. Provided an API for testing messages of this format. (4a51035) Introduced the new API for building failure messages in a "key: value" format. See Subject.failWithActual and failWithoutActual, which use the new Fact class. (e06ca85) Changed the old API's failure messages to automatically add a "name: ..." field if the user called named(). In some cases, this adds a name where it was missing before; in others, it duplicates a name that is already present. The long-term fix for this will be to migrate to the new failure API, which always includes the name once, and possibly also to delete named() in favor of withMessage(). (911c939) Deprecated failWithRawMessageAndCause. Truth automatically attaches the cause if it's part of the assertion chain. If not, see the deprecation docs for the workaround. (3622e9c) Deprecated failComparing. Use check("foo").that(actual().foo()).isEqualTo(expectedFoo). (2db2a4f) Deprecated the remaining legacy fail* methods. (1f9b2d6) Hid protected method IterableSubject.failWithBadResultsAndSuffix() (5becbfe). Started throwing ComparisonFailure from MapSubject.containsEntry. (4330ec6) Started throwing ComparisonFailure from assertThat(singleElementIterable).containsExactly(otherSingleElementIterable). (e44edd1) Added code to remove Runner and Statement frames from the stack trace. (d2bb074) Added StringSubject.ignoringCase() (13e8054) Added ignoringExtraRepeatedFieldElements() to ProtoTruth. (f070204) Added comparingExpectedFieldsOnly() to ProtoTruth. (08908c1) Removed deprecated MultimapSubject.containsExactly(Multimap). Use containsExactlyEntriesIn(Multimap). (containsExactly(Object k0, Object v0, Object... rest) continues to exist.) (9c80ad5) Removed deprecated isPartiallyOrdered() methods. Use isOrdered() (5becbfe). Started throwing UOE from IterableSubject.isNoneOf() and isNotIn(). (46c8d3d) Switched to Checker Framework @NullableDecl instead of jsr305 @nullable. Tools that read these annotations may need to be updated to recognize the new annotation. (10ee459)
* Update Truth to 0.42 0.42 Made various dependency fixes and upgrades, including fixing #473 and #467. Note that some annotations-only dependencies are now no longer <provided>. See google/guava#2721 for details, but in short, feel free to exclude them if that works for your setup. Fixed NPE in MapSubject.containsExactly (#468). 0.41 Changed most of Truth's failure messages to a multi-line, key-value format. Provided an API for testing messages of this format. (4a51035) Introduced the new API for building failure messages in a "key: value" format. See Subject.failWithActual and failWithoutActual, which use the new Fact class. (e06ca85) Changed the old API's failure messages to automatically add a "name: ..." field if the user called named(). In some cases, this adds a name where it was missing before; in others, it duplicates a name that is already present. The long-term fix for this will be to migrate to the new failure API, which always includes the name once, and possibly also to delete named() in favor of withMessage(). (911c939) Deprecated failWithRawMessageAndCause. Truth automatically attaches the cause if it's part of the assertion chain. If not, see the deprecation docs for the workaround. (3622e9c) Deprecated failComparing. Use check("foo").that(actual().foo()).isEqualTo(expectedFoo). (2db2a4f) Deprecated the remaining legacy fail* methods. (1f9b2d6) Hid protected method IterableSubject.failWithBadResultsAndSuffix() (5becbfe). Started throwing ComparisonFailure from MapSubject.containsEntry. (4330ec6) Started throwing ComparisonFailure from assertThat(singleElementIterable).containsExactly(otherSingleElementIterable). (e44edd1) Added code to remove Runner and Statement frames from the stack trace. (d2bb074) Added StringSubject.ignoringCase() (13e8054) Added ignoringExtraRepeatedFieldElements() to ProtoTruth. (f070204) Added comparingExpectedFieldsOnly() to ProtoTruth. (08908c1) Removed deprecated MultimapSubject.containsExactly(Multimap). Use containsExactlyEntriesIn(Multimap). (containsExactly(Object k0, Object v0, Object... rest) continues to exist.) (9c80ad5) Removed deprecated isPartiallyOrdered() methods. Use isOrdered() (5becbfe). Started throwing UOE from IterableSubject.isNoneOf() and isNotIn(). (46c8d3d) Switched to Checker Framework @NullableDecl instead of jsr305 @nullable. Tools that read these annotations may need to be updated to recognize the new annotation. (10ee459) * Update NulLAway to 0.6.0 * Update ErrorProne to 2.3.2 Highlights: Opt-in check AndroidJdkLibsChecker enforces which JDK libraries can be used in Android applications, and, with the -XepOpt:Android:Java8Libs flag, can allow select Java 8 library support via https://developer.android.com/studio/write/java8-support. Look out for this in bazel.build after the next release. Immutable{Annotation,Enum}Checker now requires the Error Prone @immutable annotation, not the JSR-305 @immutable annotation New Checks: Javadoc Checkers: InvalidParam, InvalidTag, InvalidThrows, ReturnFromVoid API Checkers: AndroidJdkLibsChecker, Java7ApiChecker, ApiDiffChecker AnnotateFormatMethod AnnotationPosition ArrayAsKeyOfSetOrMap AutoValueFinalMethods BadInstanceof BigDecimalEquals ClassNamedLikeTypeParameter CloseableProvides ComparingThisWithNull DeprecatedThreadMethods EqualsBrokenForNull EqualsGetClass EqualsUnsafeCast EqualsUsingHashCode EqualsWrongThing ExpectedExceptionRefactoring ExtendingJUnitAssert FloatingPointAssertionWithinEpsilon ImmutableRefactoring InconsistentHashCode InjectOnMemberAndConstructor LockNotBeforeTry MathAbsoluteRandom MathRoundIntLong MissingTestCall ModifiedButNotUsed NoFunctionalReturnType NullableDereference ObjectsHashCodePrimitive ProtoRedundantSet ProtosAsKeyOfSetOrMap SubstringOfZero SwigMemoryLeak SystemExitOutsideMain TestExceptionRefactoring ThreadPriorityCheck ToStringReturnsNull TruthAssertExpected TypeNameShadowing UndefinedEquals UnnecessaryParentheses UnsafeReflectiveConstructionCast UnusedException VariableNameSameAsType * AGP 3.2.1 * Fix misconfigured errorProne javac
This is necessary for some forthcoming changes that migrate to methods introduced in that version: https://github.com/google/truth/releases/tag/release_0_44 While here, move diffutils from runtime_deps to deps. This is unlikely to matter in practice, but in principle it's the right thing, and it *might* matter if static analysis or other build tools (-Xlint:all?) went digging into the deps of Truth at compile time. Such problems (albeit when the dependency's API is publicly visible through the using library) are what prompted the creation of java_import#deps (internal Google bug 23781162). For other problems (that might also not apply here), see google/guava#2721
I was going to say that this also paves the way for including the annotation as a non-optional dependency, should we wish to follow our Guava precedent for annotations: - google/guava#2824 - google/guava#2721 But I see that it's retention=SOURCE anyway, so there isn't much reason to do that -- except maybe consistency with other annotation packages someday. (Maybe it's still a negative then, as it might still let people rely on our transitive dependency?) I think the relationship of all this to Java 11 was that I might have to set an Automatic-Module-Name on AutoService, and it makes more sense to set it after we've done the processor-vs.-annotation artifact split. Once I was upgrading, it made sense to set up the annotation processor the Right Away, now that we're using a version in which that works. (Or maybe it always worked but now it's nice that it gets the processor off the classpath?) Or maybe there was some other reason for the change to the annotation-processor setup; once again, I forget. It looks like it might have been that AutoService stops running when I switch how we run Error Prone. Hopefully this was the solution :) But it's probably a good idea in any case. This CL is basically following the "alternatively" instructions in https://github.com/google/auto/blob/master/value/userguide/index.md#in-pomxml ...even though the AutoService instructions haven't been similarly updated yet: https://github.com/google/auto/tree/master/service#download ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=272720556
I was going to say that this also paves the way for including the annotation as a non-optional dependency, should we wish to follow our Guava precedent for annotations: - google/guava#2824 - google/guava#2721 But I see that it's retention=SOURCE anyway, so there isn't much reason to do that -- except maybe consistency with other annotation packages someday. (Maybe it's still a negative then, as it might still let people rely on our transitive dependency?) I think the relationship of all this to Java 11 was that I might have to set an Automatic-Module-Name on AutoService, and it makes more sense to set it after we've done the processor-vs.-annotation artifact split. Once I was upgrading, it made sense to set up the annotation processor the Right Away, now that we're using a version in which that works. (Or maybe it always worked but now it's nice that it gets the processor off the classpath?) Or maybe there was some other reason for the change to the annotation-processor setup; once again, I forget. It looks like it might have been that AutoService stops running when I switch how we run Error Prone. Hopefully this was the solution :) But it's probably a good idea in any case. This CL is basically following the "alternatively" instructions in https://github.com/google/auto/blob/master/value/userguide/index.md#in-pomxml ...even though the AutoService instructions haven't been similarly updated yet: https://github.com/google/auto/tree/master/service#download ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=272720556
* Update Truth to 0.42 0.42 Made various dependency fixes and upgrades, including fixing #473 and #467. Note that some annotations-only dependencies are now no longer <provided>. See google/guava#2721 for details, but in short, feel free to exclude them if that works for your setup. Fixed NPE in MapSubject.containsExactly (#468). 0.41 Changed most of Truth's failure messages to a multi-line, key-value format. Provided an API for testing messages of this format. (4a51035) Introduced the new API for building failure messages in a "key: value" format. See Subject.failWithActual and failWithoutActual, which use the new Fact class. (e06ca85) Changed the old API's failure messages to automatically add a "name: ..." field if the user called named(). In some cases, this adds a name where it was missing before; in others, it duplicates a name that is already present. The long-term fix for this will be to migrate to the new failure API, which always includes the name once, and possibly also to delete named() in favor of withMessage(). (911c939) Deprecated failWithRawMessageAndCause. Truth automatically attaches the cause if it's part of the assertion chain. If not, see the deprecation docs for the workaround. (3622e9c) Deprecated failComparing. Use check("foo").that(actual().foo()).isEqualTo(expectedFoo). (2db2a4f) Deprecated the remaining legacy fail* methods. (1f9b2d6) Hid protected method IterableSubject.failWithBadResultsAndSuffix() (5becbfe). Started throwing ComparisonFailure from MapSubject.containsEntry. (4330ec6) Started throwing ComparisonFailure from assertThat(singleElementIterable).containsExactly(otherSingleElementIterable). (e44edd1) Added code to remove Runner and Statement frames from the stack trace. (d2bb074) Added StringSubject.ignoringCase() (13e8054) Added ignoringExtraRepeatedFieldElements() to ProtoTruth. (f070204) Added comparingExpectedFieldsOnly() to ProtoTruth. (08908c1) Removed deprecated MultimapSubject.containsExactly(Multimap). Use containsExactlyEntriesIn(Multimap). (containsExactly(Object k0, Object v0, Object... rest) continues to exist.) (9c80ad5) Removed deprecated isPartiallyOrdered() methods. Use isOrdered() (5becbfe). Started throwing UOE from IterableSubject.isNoneOf() and isNotIn(). (46c8d3d) Switched to Checker Framework @NullableDecl instead of jsr305 @nullable. Tools that read these annotations may need to be updated to recognize the new annotation. (10ee459) * Update NulLAway to 0.6.0 * Update ErrorProne to 2.3.2 Highlights: Opt-in check AndroidJdkLibsChecker enforces which JDK libraries can be used in Android applications, and, with the -XepOpt:Android:Java8Libs flag, can allow select Java 8 library support via https://developer.android.com/studio/write/java8-support. Look out for this in bazel.build after the next release. Immutable{Annotation,Enum}Checker now requires the Error Prone @immutable annotation, not the JSR-305 @immutable annotation New Checks: Javadoc Checkers: InvalidParam, InvalidTag, InvalidThrows, ReturnFromVoid API Checkers: AndroidJdkLibsChecker, Java7ApiChecker, ApiDiffChecker AnnotateFormatMethod AnnotationPosition ArrayAsKeyOfSetOrMap AutoValueFinalMethods BadInstanceof BigDecimalEquals ClassNamedLikeTypeParameter CloseableProvides ComparingThisWithNull DeprecatedThreadMethods EqualsBrokenForNull EqualsGetClass EqualsUnsafeCast EqualsUsingHashCode EqualsWrongThing ExpectedExceptionRefactoring ExtendingJUnitAssert FloatingPointAssertionWithinEpsilon ImmutableRefactoring InconsistentHashCode InjectOnMemberAndConstructor LockNotBeforeTry MathAbsoluteRandom MathRoundIntLong MissingTestCall ModifiedButNotUsed NoFunctionalReturnType NullableDereference ObjectsHashCodePrimitive ProtoRedundantSet ProtosAsKeyOfSetOrMap SubstringOfZero SwigMemoryLeak SystemExitOutsideMain TestExceptionRefactoring ThreadPriorityCheck ToStringReturnsNull TruthAssertExpected TypeNameShadowing UndefinedEquals UnnecessaryParentheses UnsafeReflectiveConstructionCast UnusedException VariableNameSameAsType * AGP 3.2.1 * Fix misconfigured errorProne javac
If anyone runs into this problem while using Java Modules, see #7233 (comment) for a solution. |
When compiling code that depends on Guava 21.0, [Edit: I mistakenly said 20.0 originally] using Maven, I get many warning messages like this:
I do not use the errorprone library in my code, so this error message is due to its use by Guava.
Obviously, these are only warning messages and are not critical.
The text was updated successfully, but these errors were encountered: