aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcpovirk <cpovirk@google.com>2021-09-27 08:02:09 -0700
committerGoogle Java Core Libraries <java-core-libraries-team+copybara@google.com>2021-09-27 08:04:14 -0700
commit0ad6d6d9e1a2eab6f05c7609868db494b5e3d212 (patch)
tree038d7e295f69f0b6b30ca2d18a4ea1e8dd52c8be
parent7396bab41807702f2ce94517d0f58b8e52f603f8 (diff)
downloadguava-0ad6d6d9e1a2eab6f05c7609868db494b5e3d212.tar.gz
Strip `@Nullable` annotations from GWT sources.
If we use `@Nullable`, the GWT compiler requires access to _the source code for `@Nullable`_ -- at least when `@Nullable` appears in _certain_ locations (type parameter bounds, type arguments, maybe others?). When we began using those annotations in those locations, I inserted a workaround into our own build to supply access to the source code for `@Nullable`. (That required not only depending on that source code but also providing a hacky, local `.gwt.xml` file. That means that our _users_ would _also_ need to do both of those things, which we really shouldn't require.) I had intended to improve upon this before the 31.0 release, but I didn't make a note about it in the right place :( The fix of simply removing the annotations works fine, since only the GWT compiler ever sees these sources, and it doesn't care about type annotations. (OK, our j2cl users could eventually care about the lack of annotations. But we haven't yet we applied `@NullMarked` to our classes externally, so the difference to them is between "lack of nullness information" and "possibly null" -- which means essentially nothing.) (One way to look at this CL is as an edited, very partial rollback of CL 364918297.) RELNOTES=Fixed [GWT compilation failure](https://groups.google.com/g/guava-discuss/c/I32pgyyj1N8/m/pXcyky2hAgAJ) introduced in release 31.0. PiperOrigin-RevId: 399190627
-rw-r--r--guava-gwt/pom.xml21
-rw-r--r--guava-gwt/src/com/google/common/ForceGuavaCompilation.gwt.xml1
2 files changed, 6 insertions, 16 deletions
diff --git a/guava-gwt/pom.xml b/guava-gwt/pom.xml
index 0d61f395d..21a441313 100644
--- a/guava-gwt/pom.xml
+++ b/guava-gwt/pom.xml
@@ -107,11 +107,6 @@
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
</dependency>
- <dependency>
- <groupId>org.checkerframework</groupId>
- <artifactId>checker-qual</artifactId>
- <classifier>sources</classifier>
- </dependency>
</dependencies>
<build>
<plugins>
@@ -134,8 +129,6 @@
<!-- 2. Don't include the source in the jar (since that would let users depend on it from GWT client code, which is compiled from source). -->
<exclude>**/ForceGuavaCompilation*</exclude>
<exclude>**/DummyJavadocClass*</exclude>
- <!-- (unrelated interruption: Also don't include our fabricated CF GWT module descriptor. -->
- <exclude>**/Qual.gwt.xml</exclude>
</excludes>
</configuration>
</plugin>
@@ -146,8 +139,6 @@
<!-- 3. Don't include it in the source jar (since it's really more of a "test" than it is production code). -->
<exclude>**/ForceGuavaCompilation*</exclude>
<exclude>**/DummyJavadocClass*</exclude>
- <!-- (unrelated interruption: Also don't include our fabricated CF GWT module descriptor. I don't think anyone should be using our *sources* jar, anyway, at least not as an input to GWT compilation, but it seems safest to exclude here, just as we do for maven-jar-plugin, to be safe. -->
- <exclude>**/Qual.gwt.xml</exclude>
</excludes>
</configuration>
</plugin>
@@ -308,17 +299,17 @@
<include name="**/InternalFutureFailureAccess.java" />
</fileset>
</copy>
- <!-- We fabricate a GWT module to cover the CF annotations. Then we inherit it in ForceGuavaCompilation.gwt.xml. -->
- <echo file="${project.build.directory}/guava-gwt-sources/org/checkerframework/checker/nullness/qual/Qual.gwt.xml">
- &lt;module&gt;&lt;source path="" /&gt;&lt;/module&gt;
- </echo>
- <!-- TODO(cpovirk): DO NOT RELEASE in this state: I suspect that downstream users of guava-gwt will see their compilation fail from the "missing" CF annotations (whether because those sources are missing entirely or because they're present but without a module descriptor). -->
- <!-- In contrast to what we do with our *own* sources (i.e., those from guava, guava-testlib, and guava-tests), we *don't* copy the CF annotations to guava-gwt-sources (and so we don't need to unpack them ourselves at all). If we did, they would end up in our generated jar. And we don't need to, anyway: The GWT plugin picks them up automatically because of the <classifier>source</classifier> dependency above. -->
<copy toDir="${project.build.directory}/guava-test-gwt-sources">
<fileset dir="${project.build.directory}/guava-test-sources">
<contains text="@GwtCompatible"/>
</fileset>
</copy>
+ <replace token="@Nullable" value="">
+ <fileset dir="${project.build.directory}">
+ <include name="guava-gwt-sources/**/*.java"/>
+ <include name="guava-test-gwt-sources/**/*.java"/>
+ </fileset>
+ </replace>
</target>
</configuration>
</execution>
diff --git a/guava-gwt/src/com/google/common/ForceGuavaCompilation.gwt.xml b/guava-gwt/src/com/google/common/ForceGuavaCompilation.gwt.xml
index 86373cf5e..93f5404da 100644
--- a/guava-gwt/src/com/google/common/ForceGuavaCompilation.gwt.xml
+++ b/guava-gwt/src/com/google/common/ForceGuavaCompilation.gwt.xml
@@ -13,7 +13,6 @@
<inherits name="com.google.common.xml.Xml" />
<inherits name="com.google.thirdparty.publicsuffix.PublicSuffixPatterns" />
<inherits name="com.google.thirdparty.publicsuffix.PublicSuffixType" />
- <inherits name="org.checkerframework.checker.nullness.qual.Qual" />
<!-- com.google.common.testing.Testing is located in
GuavaTests under guava-gwt/test -->