Skip to content

Cannot use library from Java 9+ due to split package (JSR 305 vs annotations-api) #12011

Closed
@cowwoc

Description

@cowwoc

What version of gRPC-Java are you using?

1.71.0

What is your environment?

Microsoft Windows [Version 10.0.26100.3775]
openjdk version "23.0.2" 2025-01-21
OpenJDK Runtime Environment (build 23.0.2+7-58)
OpenJDK 64-Bit Server VM (build 23.0.2+7-58, mixed mode, sharing)

What did you expect to see?

No error

What did you see instead?

Compiler error when I add a dependency on gRPC-Java:

[ERROR] module com.google.protobuf reads package javax.annotation from both annotations.api and jsr305

(com.google.protobuf is not relevant, I get the same error from all modules in my project)

Steps to reproduce the bug

io.grpc:grpc-api:jar:1.71.0:compile depends on com.google.code.findbugs:jsr305:jar:3.0.2:compile but the README.md instructs Java9 users to also add a dependency on:

<dependency> <!-- necessary for Java 9+ -->
  <groupId>org.apache.tomcat</groupId>
  <artifactId>annotations-api</artifactId>
  <version>6.0.53</version>
  <scope>provided</scope>
</dependency>

Both these packages contain a javax.annotation package which means that the package is split across multiple Java Modules which is illegal in Java 9+

Consider dropping the dependency on JSR 305 as it's basically a dead project anyway.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions