truth: unknown enum constant ElementType.MODULE with Truth 1.4.3

Starting with Truth 1.4.3, compiling on Java 11+ with --release 8 produces a warning:

> Task :grpc-interop-testing:compileJava FAILED
warning: unknown enum constant ElementType.MODULE
error: warnings found and -Werror specified
1 error
1 warning

That warning message is maddening, as it tells you no context to track down the source. It’s also maddening that it works on Java 8 but not on Java 11+. I am assuming the problem here is triggered by JSpecify’s @NullMarked because its the only reference to ElementType.MODULE I’ve found to this point. And it appears you’ve already suffered from it in https://github.com/jspecify/jspecify/issues/302

I get the feeling that the only possible solution, other than “don’t use MODULE as we wait for Java 8 to die”, is a multi-release jar and tools get updated to support them. But I do wonder if Java 8’s death beats that to the finish line (not that anyone can predict Java 8’s death).

I don’t know what you can do about this. But I’m filing this issue to say “this bit me” and for the moment I’ll probably use 1.4.2 in gRPC instead of getting on 1.4.3. I was upgrading from 1.1.5 so that’s still a net win for a while.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16 (11 by maintainers)

Commits related to this issue

Most upvoted comments

I’ve released 1.4.4 with the workaround. The next Error Prone release will also include changes of its own to avoid triggering the problem.

There may still be warnings for people who combine just the right set of other circumstances (using @NullMarked at the method level in their own code with --release 8), but I think the remaining situations that we know about are rare, and Truth should at least not be a contributor any longer.

Thanks again for reporting this, especially so that we could sort things out before the upcoming JSpecify 1.0.0 release!

It would also make sense for the error to go away with JDK8, since Error Prone no longer supports that.

Oh, this is related to ErrorProne. In that case, you need to know we use two different ErrorProne versions. (Wow, you’ve got a nice perfect storm of your projects intersecting here. “So this is what bleeding edge feels like.” --You, every day 2012-2024)

Errorprone 2.10.0 on Java 8. https://github.com/grpc/grpc-java/blob/0ff3f8e4ac4c265e91b4a0379a32cf25a0a2b2f7/gradle/libs.versions.toml#L102

Errorprone 2.23.0 on Java 11+ (I have a local commit to upgrade to 2.28.0; I’m waiting for the first dependency PR to go in). https://github.com/grpc/grpc-java/blob/0ff3f8e4ac4c265e91b4a0379a32cf25a0a2b2f7/gradle/libs.versions.toml#L30