google / dagger

A fast dependency injector for Android and Java.
https://dagger.dev
Apache License 2.0
17.56k stars 2.03k forks source link

Document release that dropped compatibility with javac 8 #4654

Open cpovirk opened 1 month ago

cpovirk commented 1 month ago

In my testing with Caliper, I can build under JDK 8 with Dagger 2.50 but not with 2.51:

Caused by: java.lang.NoSuchMethodError: java.util.Optional.isEmpty()Z
    at dagger.internal.codegen.binding.BindingGraphFactory.shouldIncludeImplicitProductionModules (BindingGraphFactory.java:279)

Additionally, somewhere after 2.51 but by 2.56, I start seeing this failure even earlier:

Could not load processor class file due to 'dagger/spi/internal/shaded/androidx/room/compiler/processing/javac/JavacBasicAnnotationProcessor has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0'.

No one seems to have minded in the past year, so that's good news :)

bcorso commented 1 month ago

Thanks for the report.

I'm surprised by the first issue (Dagger 2.50 - 2.51) since we do have a check that all of the Dagger-specific class files are compatible with JDK 8 here.

However, I'm not surprised by the second issue because the check does not validate Dagger's shaded class files (which it probably should), and the shaded XProcessing dependency has been increasing its target JDK requirements quite aggressively (I think it's JDK 11 currently).

Either way, I can update the release notes to mention these changes.

cpovirk commented 1 month ago

The check definitely looks to be validating the class-file version (so it would catch the XProcessing problem if not for the caveat you mentioned), but perhaps it's not validating usage of APIs from newer versions of Java (which are still possible even with older class files). For the latter, you could try building with --release 8 (or whatever version you now want as your baseline :)) or using Animal Sniffer. That may or may not turn into a yak shave :) Thanks for having a look at the release notes.