[build] default $(JavacSource/TargetVersion)
to 1.8 for Android code
#10050
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes: #9922
Fixes: #9925
In 165cef7, we started compiling with Java 17 by default. This causes warnings in #9922 such as:
This also happens if we go back to Java 9.
We can get rid of the warning by desugaring the code to API 21:
Invoke-customs
warning #10039However, we think desugaring in itself could break something (especially for servicing).
For now, we think the safest option is:
Target 1.8 for Java code targeting Android.
Desktop Java projects can still target 17.
With these changes, tests like
BuildHasNoWarnings()
fail due to build warnings.Next:
-source
and-target
switches in the<Javac/>
MSBuild task, we can pass-Xlint:-options
tojavac
to prevent warnings about these switches being deprecated.This change is suitable for servicing in .NET 9 and the
BuildHasNoWarnings()
test now passes.