Skip to content

Commit 7e15ab3

Browse files
jjohannescpovirk
authored andcommitted
Add require static entries for annotations.
This fixes warnings that arise when javac goes looking for, e.g., `DoNotMock.value()`, which it can't find if the Guava module is not permitted to access `error_prone_annotations`. The warnings don't come up with JSpecify annotations (or perhaps J2ObjC annotations?), but it seems reasonable to declare those dependencies, too: If we were building Guava as a "normal" module (instead of [building its `module-info` separately](https://github.com/google/guava/blob/6dcc4ef29811962cfbcdbc888a0dc9c4a1efc1a3/guava/pom.xml#L101-L141)), javac would _force_ us to declare them. Signed-off-by: Jendrik Johannes <[email protected]> Fixes #7732 RELNOTES=Fixed annotation-related warnings when using Guava in modular builds. The most common such warning is `Cannot find annotation method 'value()' in type 'DoNotMock': ...`. PiperOrigin-RevId: 740355816
1 parent 40485b9 commit 7e15ab3

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

guava-testlib/src/module-info.java

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
requires java.logging;
1818
requires com.google.common;
1919
requires com.google.common.util.concurrent.internal;
20+
requires static com.google.errorprone.annotations;
21+
requires static com.google.j2objc.annotations;
22+
requires static org.jspecify;
2023

2124
exports com.google.common.collect.testing;
2225
exports com.google.common.collect.testing.features;

guava/src/module-info.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@
1616

1717
/** Google Guava */
1818
module com.google.common {
19-
requires static jdk.unsupported;
2019
requires java.logging;
2120
requires com.google.common.util.concurrent.internal;
21+
requires static jdk.unsupported;
22+
requires static com.google.errorprone.annotations;
23+
requires static com.google.j2objc.annotations;
24+
requires static org.jspecify;
2225

2326
exports com.google.common.annotations;
2427
exports com.google.common.base;

0 commit comments

Comments
 (0)