From da86203a15485ab22c4aad11668568756ef85901 Mon Sep 17 00:00:00 2001 From: Jonathan Pryor Date: Thu, 9 Jan 2025 15:45:04 -0500 Subject: [PATCH 1/3] [build] Prefer JDK-17 Context: https://github.com/dotnet/android/commit/df68c208ad02d09ebb9e6a87053343985dfc1e36 dotnet/android requires JDK-17, as of dotnet/android@df68c208. Update the dotnet/java-interop build to prefer JDK-17, for consistency. Additionally, *replace* use of `javac -source X -target X` with `javac --release X`, as this removes a build warning: EXEC : warning : [options] system modules path not set in conjunction with -source 11 --- Directory.Build.props | 2 +- build-tools/scripts/Prepare.targets | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 6b328f1f9..8aa75e7b4 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -62,7 +62,7 @@ 11 11 <_BootClassPath Condition=" '$(JreRtJarPath)' != '' ">-bootclasspath "$(JreRtJarPath)" - <_JavacSourceOptions>-source $(JavacSourceVersion) -target $(JavacTargetVersion) $(_BootClassPath) + <_JavacSourceOptions>--release $(JavacTargetVersion) $(_BootClassPath) $([System.IO.Path]::GetFullPath ('$(XamarinAndroidToolsDirectory)')) diff --git a/build-tools/scripts/Prepare.targets b/build-tools/scripts/Prepare.targets index 2618d81e3..4488ec51c 100644 --- a/build-tools/scripts/Prepare.targets +++ b/build-tools/scripts/Prepare.targets @@ -15,8 +15,8 @@ <_MaxJdk>$(MaxJdkVersion) <_MaxJdk Condition=" '$(_MaxJdk)' == '' ">$(JI_MAX_JDK) - $(JAVA_HOME_11_X64) $(JAVA_HOME_17_X64) + $(JAVA_HOME_11_X64) Date: Thu, 9 Jan 2025 17:11:08 -0500 Subject: [PATCH 2/3] Update Xamarin.Android.Tools.Bytecode-Tests New JDK, new `.class` output. --- .../JavaEnumTests.cs | 7 ++++++- .../JavaTypeTests.cs | 14 +++++++------- .../ModuleInfoTests.cs | 2 +- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/tests/Xamarin.Android.Tools.Bytecode-Tests/JavaEnumTests.cs b/tests/Xamarin.Android.Tools.Bytecode-Tests/JavaEnumTests.cs index da192250b..50ee71e25 100644 --- a/tests/Xamarin.Android.Tools.Bytecode-Tests/JavaEnumTests.cs +++ b/tests/Xamarin.Android.Tools.Bytecode-Tests/JavaEnumTests.cs @@ -22,7 +22,7 @@ public void ClassFileDescription () new ExpectedTypeDeclaration { MajorVersion = 0x37, MinorVersion = 0, - ConstantPoolCount = 53, + ConstantPoolCount = 55, AccessFlags = ClassAccessFlags.Final | ClassAccessFlags.Super | ClassAccessFlags.Enum, FullName = "com/xamarin/JavaEnum", Superclass = new TypeInfo ("java/lang/Enum", "Ljava/lang/Enum;"), @@ -71,6 +71,11 @@ public void ClassFileDescription () AccessFlags = MethodAccessFlags.Public, ReturnDescriptor = "I", }, + new ExpectedMethodDeclaration { + Name = "$values", + AccessFlags = MethodAccessFlags.Private | MethodAccessFlags.Static | MethodAccessFlags.Synthetic, + ReturnDescriptor = "[Lcom/xamarin/JavaEnum;", + }, new ExpectedMethodDeclaration { Name = "", AccessFlags = MethodAccessFlags.Static, diff --git a/tests/Xamarin.Android.Tools.Bytecode-Tests/JavaTypeTests.cs b/tests/Xamarin.Android.Tools.Bytecode-Tests/JavaTypeTests.cs index 6039d0598..4ec9dbe3d 100644 --- a/tests/Xamarin.Android.Tools.Bytecode-Tests/JavaTypeTests.cs +++ b/tests/Xamarin.Android.Tools.Bytecode-Tests/JavaTypeTests.cs @@ -35,6 +35,12 @@ public void ClassFile_WithJavaType_class () new TypeInfo ("com/xamarin/IJavaInterface", "Lcom/xamarin/IJavaInterface;Ljava/util/List;>;"), }, InnerClasses = { + new ExpectedInnerClassInfo { + InnerClassName = "com/xamarin/JavaType$1", + OuterClassName = null, + InnerName = null, + AccessFlags = 0, + }, new ExpectedInnerClassInfo { InnerClassName = "com/xamarin/JavaType$ASC", OuterClassName = "com/xamarin/JavaType", @@ -59,12 +65,6 @@ public void ClassFile_WithJavaType_class () InnerName = "MyStringList", AccessFlags = 0, }, - new ExpectedInnerClassInfo { - InnerClassName = "com/xamarin/JavaType$1", - OuterClassName = null, - InnerName = null, - AccessFlags = 0, - }, new ExpectedInnerClassInfo { InnerClassName = "com/xamarin/JavaType$RNC$RPNC", OuterClassName = "com/xamarin/JavaType$RNC", @@ -149,7 +149,7 @@ public void ClassFile_WithJavaType_class () Name = "STATIC_FINAL_STRING", Descriptor = "Ljava/lang/String;", AccessFlags = FieldAccessFlags.Public | FieldAccessFlags.Static | FieldAccessFlags.Final, - ConstantValue = "String(stringIndex=190 Utf8=\"Hello, \\\"embedded\0Nulls\" and \ud83d\udca9!\")", + ConstantValue = "String(stringIndex=101 Utf8=\"Hello, \\\"embedded\0Nulls\" and \ud83d\udca9!\")", }, new ExpectedFieldDeclaration { Name = "STATIC_FINAL_BOOL_FALSE", diff --git a/tests/Xamarin.Android.Tools.Bytecode-Tests/ModuleInfoTests.cs b/tests/Xamarin.Android.Tools.Bytecode-Tests/ModuleInfoTests.cs index f4019c831..035cc7083 100644 --- a/tests/Xamarin.Android.Tools.Bytecode-Tests/ModuleInfoTests.cs +++ b/tests/Xamarin.Android.Tools.Bytecode-Tests/ModuleInfoTests.cs @@ -18,7 +18,7 @@ public void ClassFile () new ExpectedTypeDeclaration { MajorVersion = 0x37, MinorVersion = 0, - ConstantPoolCount = 13, + ConstantPoolCount = 12, AccessFlags = ClassAccessFlags.Module, FullName = "module-info", }.Assert (c); From adefc06d0a276cfb9df87ab9207c13c222ce1288 Mon Sep 17 00:00:00 2001 From: Jonathan Pryor Date: Fri, 10 Jan 2025 20:29:53 -0500 Subject: [PATCH 3/3] New JDK, new XML output?! Context: 7a32bb976ab41dca91f6cff59b8caea9d01ea53d Context: https://bugs.openjdk.org/browse/JDK-8223291 JDK-8223291 was fixed in JDK-14, which is presumably why XML output changed. Again. Update expected XML reference files so that tests pass with JDK-17. (Which means these tests will *only* pass with JDK-17, and later if we're lucky, but will *fail* with JDK-11.) --- .../android/JavaSourceUtilsOptionsTest.java | 2 - .../android/JavadocXmlGeneratorTest.java | 9 +- .../src/test/resources/UnresolvedTypes.xml | 6 +- .../com/microsoft/android/DemoInfo.xml | 36 +--- .../com/microsoft/android/JavaType.xml | 192 +++++------------- .../resources/com/microsoft/android/Outer.xml | 70 ++----- 6 files changed, 88 insertions(+), 227 deletions(-) diff --git a/tools/java-source-utils/src/test/java/com/microsoft/android/JavaSourceUtilsOptionsTest.java b/tools/java-source-utils/src/test/java/com/microsoft/android/JavaSourceUtilsOptionsTest.java index 771b5f85c..34f684481 100644 --- a/tools/java-source-utils/src/test/java/com/microsoft/android/JavaSourceUtilsOptionsTest.java +++ b/tools/java-source-utils/src/test/java/com/microsoft/android/JavaSourceUtilsOptionsTest.java @@ -9,8 +9,6 @@ import org.junit.Test; -import jdk.nashorn.internal.AssertsEnabled; - import static org.junit.Assert.*; public class JavaSourceUtilsOptionsTest { diff --git a/tools/java-source-utils/src/test/java/com/microsoft/android/JavadocXmlGeneratorTest.java b/tools/java-source-utils/src/test/java/com/microsoft/android/JavadocXmlGeneratorTest.java index 93eb5de4f..9215ad69a 100644 --- a/tools/java-source-utils/src/test/java/com/microsoft/android/JavadocXmlGeneratorTest.java +++ b/tools/java-source-utils/src/test/java/com/microsoft/android/JavadocXmlGeneratorTest.java @@ -99,9 +99,12 @@ private static void testWritePackages(final JniPackagesInfo packagesInfo, final generator.writePackages(packagesInfo); generator.close(); - // try (FileOutputStream o = new FileOutputStream(assertDescription + "-jonp.xml")) { - // bytes.writeTo(o); - // } + + final File actual = new File(assertDescription + "-jonp.xml"); + try (FileOutputStream o = new FileOutputStream(actual)) { + bytes.writeTo(o); + } assertEquals(assertDescription, expected, bytes.toString()); + actual.delete(); } } diff --git a/tools/java-source-utils/src/test/resources/UnresolvedTypes.xml b/tools/java-source-utils/src/test/resources/UnresolvedTypes.xml index 8c175a3cf..89762f592 100644 --- a/tools/java-source-utils/src/test/resources/UnresolvedTypes.xml +++ b/tools/java-source-utils/src/test/resources/UnresolvedTypes.xml @@ -4,11 +4,9 @@ - - - +JNI Sig: method.([L.*example.name.UnresolvedParameterType;)L.*UnresolvedReturnType;]]> diff --git a/tools/java-source-utils/src/test/resources/com/microsoft/android/DemoInfo.xml b/tools/java-source-utils/src/test/resources/com/microsoft/android/DemoInfo.xml index bd6cd818b..04670d3ea 100644 --- a/tools/java-source-utils/src/test/resources/com/microsoft/android/DemoInfo.xml +++ b/tools/java-source-utils/src/test/resources/com/microsoft/android/DemoInfo.xml @@ -2,57 +2,39 @@ - - - + - - .(ILjava/lang/String;)V]]> - + .(ILjava/lang/String;)V]]> - - - + - - - + - - - + - - - + - - - + - - - + - - - + diff --git a/tools/java-source-utils/src/test/resources/com/microsoft/android/JavaType.xml b/tools/java-source-utils/src/test/resources/com/microsoft/android/JavaType.xml index 7554cea00..873dc42be 100644 --- a/tools/java-source-utils/src/test/resources/com/microsoft/android/JavaType.xml +++ b/tools/java-source-utils/src/test/resources/com/microsoft/android/JavaType.xml @@ -2,192 +2,122 @@ - - - + - - Paragraphs of text? -@return some value]]> - +@return some value]]> - - ]]> - +@param ]]> - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + @@ -195,73 +125,49 @@ - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + diff --git a/tools/java-source-utils/src/test/resources/com/microsoft/android/Outer.xml b/tools/java-source-utils/src/test/resources/com/microsoft/android/Outer.xml index aec452fb2..e073732d1 100644 --- a/tools/java-source-utils/src/test/resources/com/microsoft/android/Outer.xml +++ b/tools/java-source-utils/src/test/resources/com/microsoft/android/Outer.xml @@ -2,103 +2,77 @@ - - - +JNI sig: Lexample/Outer;]]> - - (java.lang.Object value) + (java.lang.Object value) -JNI sig: (Ljava/lang/Object;)V]]> - +JNI sig: (Ljava/lang/Object;)V]]> - - list) + list)

This is a paragraph. Yay?

JNI sig: (Ljava/util/List;)Ljava/lang/Error; @param list just some random items -@return some value]]> -
+@return some value]]>
- - - +JNI sig: ([Ljava/lang/String;)V]]> - - - +JNI sig: (Ljava/lang/CharSequence;[S[Ljava/lang/Appendable;)Ljava/lang/Appendable;]]>
- - - + - - - + - - - +@throws Throwable never, just because]]> - - - + - - - + - - map) + map) JNI sig: map(Ljava/util/Map;)V -@param map]]> - +@param map]]> - - - +JNI sig: Lexample/Outer$MyAnnotation;]]> - - - +@return some random keys]]>