Skip to content

Commit 738de61

Browse files
authored
[build] Remove support for JDK 8. (#1120)
Context: 7a32bb9 Context: https://stackoverflow.com/questions/55853220/handling-change-in-newlines-by-xml-transformation-for-cdata-from-java-8-to-java Context: https://bugs.java.com/bugdatabase/view_bug?bug_id=8223291 **Background**: Since commit bc5bcf4, *two* JDKs were required in order to *fully* build and test Java.Interop: JDK 1.8 and JDK-11. This is because `src/Java.Interop` requires JDK-11+ to build, while some unit tests required JDK 1.8 to pass (because Java XML output changed between JDK 1.8 and JDK-11; see also 7a32bb9). Recently, a question arose: how well does .NET Android work with JDK 17? ([Android Studio recently bumped][0] the bundled JDK from JDK-11 to JDK-17.) The "straightforward" approach of "provision JDK-17 and just build everything with JDK-17" quickly meant that Java.Interop needed to build under JDK-17. This in turn segued into a "how do I make the MSBuild property meanings clearer", as `$(JavaCPath)` would be for JDK 1.8, while `$(JavaC11Path)` was for JDK-11, but with JDK-17 being provisioned `$(JavaC11Path)` *actually* was for JDK-17, which is just confusing. After discussion, we decided that we don't need to continue using JDK 1.8 anymore. Android API-31 requires JDK-11 in order to use various Android SDK build tools, and the Google Play Store requires a target SDK version of API-33 starting 2023-Aug. There is not much point in maintaining JDK 1.8 support. JDK 11 or later is now required. Update to use Gradle 8.1.1. This is needed for later JDK-17 support. `java/util/Collection.java` existed to help test API documentation import (when `$ANDROID_SDK_PATH` is set). JDK-11 does not support compiling `java/util/Collection.java` anymore; it errors out with: java/java/util/Collection.java:1: error: package exists in another module: java.base package java.util; ^ "Rename" this type to `android/animation/TypeEvaluator.java`, and update the API documentation import tests accordingly. Update the `ExpectedTypeDeclaration.MajorVersion` values to 0x37. The `.class` files for nested types has seen the addition of a new `NestHost` constant; see also: * https://docs.oracle.com/javase/specs/jvms/se11/html/jvms-4.html#jvms-4.7.28 * https://docs.oracle.com/javase/specs/jvms/se11/html/jvms-5.html#jvms-5.4.4 Update `ExpectedTypeDeclaration.ConstantPoolCount` as appropriate. Additional `NestHost`-related fallout is that `JavaType.class` now includes `com/xamarin/JavaType$RNC$RPNC` in the `InnerClasses` table. Update `tools/java-source-utils` unit tests so that JDK-11 can now be used to run (and pass!) the unit tests. (This previously required JDK 1.8.) [0]: https://web.archive.org/web/20230507035529/https://developer.android.com/studio/releases/#jdk-17
1 parent 4d47df8 commit 738de61

34 files changed

+354
-216
lines changed

Configuration.Override.props.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
4-
<JdkJvmPath>/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre/jli/libjli.dylib</JdkJvmPath>
4+
<JdkJvmPath>/Library/Java/JavaVirtualMachines/microsoft-11.jdk/Contents/Home/lib/jli/libjli.dylib</JdkJvmPath>
55
<MonoFrameworkPath>/Library/Frameworks/Mono.framework/Libraries/libmonosgen-2.0.1.dylib</MonoFrameworkPath>
66
<UtilityOutputFullPath>$(MSBuildThisFileDirectory)bin\$(Configuration)\</UtilityOutputFullPath>
77
</PropertyGroup>
88
<ItemGroup>
99
<!-- JDK C `include` directories -->
10-
<JdkIncludePath Include="/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/include" />
11-
<JdkIncludePath Include="/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/include/darwin" />
10+
<JdkIncludePath Include="/Library/Java/JavaVirtualMachines/microsoft-11.jdk/Contents/Home/include" />
11+
<JdkIncludePath Include="/Library/Java/JavaVirtualMachines/microsoft-11.jdk/Contents/Home/include/darwin" />
1212
</ItemGroup>
1313
<ItemGroup>
1414
<!-- Mono C `include` directories -->

Directory.Build.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@
5858
<GradleHome Condition=" '$(GradleHome)' == '' ">$(MSBuildThisFileDirectory)build-tools\gradle</GradleHome>
5959
<GradleWPath Condition=" '$(GradleWPath)' == '' ">$(GradleHome)\gradlew</GradleWPath>
6060
<GradleArgs Condition=" '$(GradleArgs)' == '' ">--stacktrace --no-daemon</GradleArgs>
61-
<JavacSourceVersion Condition=" '$(JavacSourceVersion)' == '' ">1.8</JavacSourceVersion>
62-
<JavacTargetVersion Condition=" '$(JavacTargetVersion)' == '' ">1.8</JavacTargetVersion>
61+
<JavacSourceVersion Condition=" '$(JavacSourceVersion)' == '' ">11</JavacSourceVersion>
62+
<JavacTargetVersion Condition=" '$(JavacTargetVersion)' == '' ">11</JavacTargetVersion>
6363
<_BootClassPath Condition=" '$(JreRtJarPath)' != '' ">-bootclasspath "$(JreRtJarPath)"</_BootClassPath>
6464
<_JavacSourceOptions>-source $(JavacSourceVersion) -target $(JavacTargetVersion) $(_BootClassPath)</_JavacSourceOptions>
6565
</PropertyGroup>

build-tools/automation/azure-pipelines.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ pr:
2020
variables:
2121
RunningOnCI: true
2222
Build.Configuration: Release
23-
MaxJdkVersion: 8
2423
DotNetCoreVersion: 7.x
2524
DotNetTargetFramework: net7.0
2625
NetCoreTargetFrameworkPathSuffix: -$(DotNetTargetFramework)

build-tools/automation/templates/core-build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ steps:
66
displayName: Prepare Solution
77
inputs:
88
projects: Java.Interop.sln
9-
arguments: '-c $(Build.Configuration) -target:Prepare -p:MaxJdkVersion=$(MaxJdkVersion)'
9+
arguments: '-c $(Build.Configuration) -target:Prepare'
1010

1111
- task: DotNetCoreCLI@2
1212
displayName: Shut down existing build server
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

build-tools/scripts/Prepare.targets

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,15 @@
1515
<PropertyGroup>
1616
<_MaxJdk>$(MaxJdkVersion)</_MaxJdk>
1717
<_MaxJdk Condition=" '$(_MaxJdk)' == '' ">$(JI_MAX_JDK)</_MaxJdk>
18-
<Jdks8Root Condition=" '$(Jdks8Root)' == '' And '$(JAVA_HOME_8_X64)' != '' And Exists($(JAVA_HOME_8_X64)) ">$(JAVA_HOME_8_X64)</Jdks8Root>
18+
<JdksRoot Condition=" '$(JdksRoot)' == '' And '$(JAVA_HOME_11_X64)' != '' And Exists($(JAVA_HOME_11_X64)) ">$(JAVA_HOME_11_X64)</JdksRoot>
1919
</PropertyGroup>
2020
<JdkInfo
21-
JdksRoot="$(Jdks8Root)"
21+
JdksRoot="$(JdksRoot)"
2222
MakeFragmentFile="$(MSBuildThisFileDirectory)..\..\bin\Build$(Configuration)\JdkInfo.mk"
2323
MaximumJdkVersion="$(_MaxJdk)"
2424
DotnetToolPath="$(DotnetToolPath)"
2525
PropertyFile="$(_TopDir)\bin\Build$(Configuration)\JdkInfo.props">
2626
<Output TaskParameter="JavaHomePath" PropertyName="_JavaSdkDirectory" />
2727
</JdkInfo>
28-
<PropertyGroup>
29-
<Jdks11Root Condition=" '$(Jdks11Root)' == '' And '$(JAVA_HOME_11_X64)' != '' And Exists($(JAVA_HOME_11_X64)) ">$(JAVA_HOME_11_X64)</Jdks11Root>
30-
</PropertyGroup>
31-
<JdkInfo
32-
JdksRoot="$(Jdks11Root)"
33-
PropertyNameModifier="11"
34-
MinimumJdkVersion="11.0"
35-
MaximumJdkVersion="11.99.0"
36-
PropertyFile="$(_TopDir)\bin\Build$(Configuration)\JdkInfo-11.props">
37-
<Output TaskParameter="JavaHomePath" PropertyName="Java11SdkDirectory"/>
38-
</JdkInfo>
3928
</Target>
4029
</Project>

src/Java.Base/Java.Base.targets

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
</ItemGroup>
1010

1111
<Target Name="_GetJavaBaseJmodPath">
12-
<PropertyGroup Condition=" '$(Java11SdkDirectory)' != '' ">
13-
<_JavaBaseJmod>$(Java11SdkDirectory)/jmods/java.base.jmod</_JavaBaseJmod>
12+
<PropertyGroup Condition=" '$(JavaSdkDirectory)' != '' ">
13+
<_JavaBaseJmod>$(JavaSdkDirectory)/jmods/java.base.jmod</_JavaBaseJmod>
1414
</PropertyGroup>
1515
</Target>
1616

tests/Xamarin.Android.Tools.Bytecode-Tests/IJavaInterfaceTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public void ClassFile_WithIJavaInterface_class ()
1616
{
1717
var c = LoadClassFile (JavaType + ".class");
1818
new ExpectedTypeDeclaration {
19-
MajorVersion = 0x34,
19+
MajorVersion = 0x37,
2020
MinorVersion = 0,
2121
ConstantPoolCount = 23,
2222
AccessFlags = ClassAccessFlags.Interface | ClassAccessFlags.Abstract,

tests/Xamarin.Android.Tools.Bytecode-Tests/JavaAnnotationTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public void ClassFile_WithJavaAnnotation_class ()
1616
{
1717
var c = LoadClassFile (JavaType + ".class");
1818
new ExpectedTypeDeclaration {
19-
MajorVersion = 0x34,
19+
MajorVersion = 0x37,
2020
MinorVersion = 0,
2121
ConstantPoolCount = 23,
2222
AccessFlags = ClassAccessFlags.Public | ClassAccessFlags.Interface | ClassAccessFlags.Abstract | ClassAccessFlags.Annotation,

tests/Xamarin.Android.Tools.Bytecode-Tests/JavaEnumTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public void ClassFileDescription ()
2020
{
2121
var c = LoadClassFile (JavaType + ".class");
2222
new ExpectedTypeDeclaration {
23-
MajorVersion = 0x34,
23+
MajorVersion = 0x37,
2424
MinorVersion = 0,
2525
ConstantPoolCount = 53,
2626
AccessFlags = ClassAccessFlags.Final | ClassAccessFlags.Super | ClassAccessFlags.Enum,

0 commit comments

Comments
 (0)