Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

class file for com.google.errorprone.annotations.CompatibleWith not found #7233

Closed
1 task done
cowwoc opened this issue May 23, 2024 · 3 comments
Closed
1 task done
Labels
type=defect Bug, not working as expected

Comments

@cowwoc
Copy link

cowwoc commented May 23, 2024

Description

As a follow-up for #2721, I am getting this problem using JDK 22, -Werror, and -Wlint:all

I tried adding:

<dependency>
	<groupId>com.google.errorprone</groupId>
	<artifactId>error_prone_annotations</artifactId>
	<version>2.26.1</version>
</dependency>

but it did not help. I will include the maven -X (full debug) output for you to review.

This only seems to occur when compiling unit tests though. default-compile works fine but default-testCompile fails

build.log

As you can see at the end of the log, errorprone is on the compiler classpath, so I'm at a loss as to why this is failing.

Expected Behavior

No compiler warnings/errors

Actual Behavior

Compiler warnings/errors

Packages

No response

Platforms

No response

Checklist

@cowwoc cowwoc added the type=defect Bug, not working as expected label May 23, 2024
@cowwoc
Copy link
Author

cowwoc commented May 23, 2024

Correction, errorprone is on the module path, not class path, but so are all the other JARs. I don't have a choice because my library uses Java Modules and if I try running with <useModulePath>false</useModulePath> I get an error in my own module-info.java. In any case, I don't think this is the source of the problem.

@cowwoc
Copy link
Author

cowwoc commented May 23, 2024

Gah! I figured it out.

If guava or the annotation JAR is placed on the module-path then the project must explicitly add requires static com.google.errorprone.annotations to its module-info; otherwise, the compiler will behave as if the class cannot be found (when in fact, it can be). You don't need to explicitly add errorprone as a dependency because guava should already do that for you (it is a transitive compile-time dependency).

Another workaround, for anyone wanting to try something different, is to add -Xlint:classfile. This will suppress these kind of warnings.

@cpovirk
Copy link
Member

cpovirk commented May 24, 2024

Ah, thanks. This is another reason for us to get our modules story in order. (I double-checked that you've been on #2970....)

(I'd not sure I was aware of -Xlint:classfile!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type=defect Bug, not working as expected
Projects
None yet
Development

No branches or pull requests

2 participants