Skip to content

Remove code from AutoServiceProcessor that read existing META-INF/services files from the CLASS_OUTPUT location and merged new @AutoService services with them. #1916

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

Closed
wants to merge 0 commits into from

Conversation

copybara-service[bot]
Copy link
Contributor

Remove code from AutoServiceProcessor that read existing META-INF/services files from the CLASS_OUTPUT location and merged new @AutoService services with them.

This behavior was untested and it's unclear what situations would actually need this behavior. Internally, nothing was broken by removing this and continuing to include it was causing problems for reasons I won't get into. If it turns out that open-source users were relying on this behavior we can add it back in with some way of turning it off.

RELNOTES=Removed AutoServiceProcessor code that read existing META-INF/services files.

@copybara-service copybara-service bot closed this Apr 4, 2025
@copybara-service copybara-service bot force-pushed the test_main_740849283 branch from f85c06c to e83617e Compare April 4, 2025 16:47
@copybara-service copybara-service bot deleted the test_main_740849283 branch April 4, 2025 16:47
@tbroyer
Copy link
Contributor

tbroyer commented Apr 4, 2025

This behavior was untested and it's unclear what situations would actually need this behavior.

AFAIK, this was to accommodate somewhat broken "incremental compilation" in some "naïve" tools (Ant probably, but possibly and more importantly Eclipse, maybe other IDEs too; it was also a problem with Maven at some point), that would call javac with only the Java source files that had changed since last compilation (possibly also other sources files that directly depended on the changed sources), so the processor wouldn't see all the @AutoService-annotated in that case and would then produce an incomplete META-INF/services file.

E.g. given A.java and B.java both containing a class annotated with @AutoService(I.class). If you call javac with both files (and whatever contains the I interface) you get an output file containing both A and B. Now modify B, without touching A; some tools will call javac with only the B.java source file, and now the processor will only see B, and the generated file will be missing A. The fix is to call javac with B.java and A.class in this case, or possibly B.java and A.java.

I have no idea if that can still be an issue in practice nowadays, I only use tools that implement incremental compilation correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant