error-prone icon indicating copy to clipboard operation
error-prone copied to clipboard

JPMS: Cannot use both annotations and type-annotations

Open codeleverage opened this issue 9 months ago • 4 comments

I'm trying to use both @Immutable and @ImmutableTypeParameter in a JPMS project. However, using annotations from both error_prone_annotations and error_prone_type_annotations doesn't work because they both export the same package.

module test.foo {
  requires com.google.errorprone.annotations;
  requires com.google.errorprone.type.annotations;
}

Compilation fails with:

[ERROR] module test.foo reads package com.google.errorprone.annotations from both com.google.errorprone.type.annotations and com.google.errorprone.annotations

Is there a path to supporting all available annotations with JPMS?

codeleverage avatar Mar 11 '25 13:03 codeleverage

I pushed a release that merges error_prone_type_annotations into error_prone_annotations, so it should be possible to just depend on error_prone_annotations to avoid the split package issue: https://github.com/google/error-prone/releases/tag/v2.37.0

cushon avatar Mar 19 '25 15:03 cushon

Stumbled on an issue where error_prone_annotations still depends on the now removed error_prone_type_annotations, here's a PR to remove that: https://github.com/google/error-prone/pull/4924

protocol7 avatar Mar 20 '25 08:03 protocol7

This is by-design (https://github.com/google/error-prone/commit/04fe8357e885ff17990b0558379bbe158397b23c)

Shouldn't this be fixed in Bazel's rules_jvm_external to properly handle relocations?

tbroyer avatar Mar 20 '25 08:03 tbroyer

Shouldn't this be fixed in Bazel's rules_jvm_external to properly handle relocations?

That's fair. It does somewhat handle relocations (https://github.com/bazel-contrib/rules_jvm_external/tree/d8af22108bd8b353a226140570008231f2921931?tab=readme-ov-file#overriding-generated-targets), but doesn't seem to handle the case where relocation target depend on the relocated artifact.

protocol7 avatar Mar 20 '25 09:03 protocol7