Skip to content

Include JSpecify annotations in -with-dependencies.jar. - #4971

Merged
copybara-service[bot] merged 1 commit into
masterfrom
test_746459384
Apr 11, 2025
Merged

copybara-service[bot] merged 1 commit into
masterfrom
test_746459384

Conversation

@copybara-service

Copy link
Copy Markdown
Contributor

Include JSpecify annotations in -with-dependencies.jar.

I don't think this is currently like javax.inject, in which the dependency is actually important to have at runtime. But quite possibly it would matter if we were to start to use NullMarked.class or something, as we used to? And anyway, I'd normally default to including everything that we can.

The exclusion that I added does appear to be necessary to avoid copying over the META-INF/versions/9/OSGI-INF/MANIFEST.MF file from JSpecify:

Manifest-Version: 1.0
Import-Package: java.lang,java.lang.annotation
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"

I don't think this is currently like [`javax.inject`](#3897), in which the dependency is actually important to have at runtime. But quite possibly it _would_ matter if we were to start to use `NullMarked.class` or something, as we [used to](#3258)? And anyway, I'd normally default to including everything that we can.

The exclusion that I added does appear to be necessary to avoid copying over the `META-INF/versions/9/OSGI-INF/MANIFEST.MF` file from JSpecify:

```
Manifest-Version: 1.0
Import-Package: java.lang,java.lang.annotation
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
```
PiperOrigin-RevId: 746527152
@copybara-service
copybara-service Bot merged commit 2517f1b into master Apr 11, 2025
@copybara-service
copybara-service Bot deleted the test_746459384 branch April 11, 2025 18:17
copybara-service Bot pushed a commit to google/guava that referenced this pull request Aug 7, 2026
...instead of in a multi-release directory.

We recently [did this for JSpecify](jspecify/jspecify#809) (released in [1.0.1](https://github.com/jspecify/jspecify/releases/tag/v1.0.1)), primarily to avoid [some problems related to `META-INF/versions/9/OSGI-INF/MANIFEST.MF`](jspecify/jspecify#484 (comment)). Granted, the _main_ domain of those problems (but [not only domain](google/error-prone#4971)!) was Android, and `guava-android` isn't ([yet](#7813)?) a module (since we don't include a `module-info.java` file there, even though plenty of module-related configuration is in place), only an "automatic module."

We're also told that [JUnit 5 has done this for years](jspecify/jspecify#484 (comment)) while also supporting Java 8, so that is yet more reason to expect it to be safe.

(This CL is an incremental bonus step in #7094.)

RELNOTES=The Guava `module-info.class` is now present at the root of the jar instead of under [a multi-release root](https://openjdk.org/jeps/238). This prevents the jar from containing a file at `META-INF/versions/9/OSGI-INF/MANIFEST.MF`, which occasionally causes [trouble for some users](jspecify/jspecify#484 (comment)).
PiperOrigin-RevId: 959773233
copybara-service Bot pushed a commit to google/guava that referenced this pull request Aug 7, 2026
...instead of in a multi-release directory.

We recently [did this for JSpecify](jspecify/jspecify#809) (released in [1.0.1](https://github.com/jspecify/jspecify/releases/tag/v1.0.1)), primarily to avoid [some problems related to `META-INF/versions/9/OSGI-INF/MANIFEST.MF`](jspecify/jspecify#484 (comment)). Granted, the _main_ domain of those problems (but [not only domain](google/error-prone#4971)!) was Android, and `guava-android` isn't ([yet](#7813)?) a module (since we don't include a `module-info.java` file there, even though plenty of module-related configuration is in place), only an "automatic module."

We're also told that [JUnit 5 has done this for years](jspecify/jspecify#484 (comment)) while also supporting Java 8, so that is yet more reason to expect it to be safe.

(This CL is an incremental bonus step in #7094.)

RELNOTES=The Guava `module-info.class` is now present at the root of the jar instead of under [a multi-release root](https://openjdk.org/jeps/238). This prevents the jar from containing a file at `META-INF/versions/9/OSGI-INF/MANIFEST.MF`, which occasionally causes [trouble for some users](jspecify/jspecify#484 (comment)).
PiperOrigin-RevId: 960605760
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

Successfully merging this pull request may close these issues.

1 participant