diff --git a/Java.Interop.sln b/Java.Interop.sln
index e119fb959..85f580bcc 100644
--- a/Java.Interop.sln
+++ b/Java.Interop.sln
@@ -1,12 +1,10 @@
-
+
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29424.173
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{C8F58966-94BF-407F-914A-8654F8B8AE3B}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xamarin.Android.Tools.JniMarshalMethodGenerator", "tools\jnimarshalmethod-gen\Xamarin.Android.Tools.JniMarshalMethodGenerator.csproj", "{D1295A8F-4F42-461D-A046-564476C10002}"
-EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "logcat-parse", "tools\logcat-parse\logcat-parse.csproj", "{7387E151-48E3-4885-B2CA-A74434A34045}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "class-parse", "tools\class-parse\class-parse.csproj", "{38C762AB-8FD1-44DE-9855-26AAE7129DC3}"
@@ -21,8 +19,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "java-interop", "src\java-in
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Java.Interop.Dynamic", "src\Java.Interop.Dynamic\Java.Interop.Dynamic.csproj", "{AD4468F8-8883-434B-9D4C-E1801BB3B52A}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Java.Interop.Export", "src\Java.Interop.Export\Java.Interop.Export.csproj", "{B501D075-6183-4E1D-92C9-F7B5002475B1}"
-EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Java.Interop.Tools.JavaSource", "src\Java.Interop.Tools.JavaSource\Java.Interop.Tools.JavaSource.csproj", "{5C0B3562-8DA0-4726-9762-75B9709ED6B7}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Desktop", "Desktop", "{0998E45F-8BCE-4791-A944-962CD54E2D80}"
@@ -47,8 +43,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Java.Interop-Tests", "tests
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Java.Interop.Dynamic-Tests", "tests\Java.Interop.Dynamic-Tests\Java.Interop.Dynamic-Tests.csproj", "{82B1DD53-69CA-4A61-B6B1-F06F1525EF4D}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Java.Interop.Export-Tests", "tests\Java.Interop.Export-Tests\Java.Interop.Export-Tests.csproj", "{82F24161-F0CA-44CC-AEC3-885D613605E0}"
-EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "logcat-parse-Tests", "tests\logcat-parse-Tests\logcat-parse-Tests.csproj", "{DB05D566-0BA0-4935-868D-689E2F03688E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xamarin.Android.Tools.Bytecode-Tests", "tests\Xamarin.Android.Tools.Bytecode-Tests\Xamarin.Android.Tools.Bytecode-Tests.csproj", "{C9FA4492-DEB0-4932-A6B8-E2C4E0581692}"
@@ -109,10 +103,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Java.Base", "src\Java.Base\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Java.Base-Tests", "tests\Java.Base-Tests\Java.Base-Tests.csproj", "{CB05E11B-B96F-4179-A4E9-5D6BDE29A8FC}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Java.Interop.Tools.Expressions", "src\Java.Interop.Tools.Expressions\Java.Interop.Tools.Expressions.csproj", "{1A0262FE-3CDB-4AF2-AAD8-65C59524FE8A}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Java.Interop.Tools.Expressions-Tests", "tests\Java.Interop.Tools.Expressions-Tests\Java.Interop.Tools.Expressions-Tests.csproj", "{211BAA88-66B1-41B2-88B2-530DBD8DF702}"
-EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Java.Interop.Tools.Maven", "src\Java.Interop.Tools.Maven\Java.Interop.Tools.Maven.csproj", "{DA458F90-218B-4FE3-995F-AF4B27895FA2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Java.Interop.Tools.Maven-Tests", "tests\Java.Interop.Tools.Maven-Tests\Java.Interop.Tools.Maven-Tests.csproj", "{6BC04C7F-949E-4F93-BF1F-E3B1DF0B888D}"
@@ -125,7 +115,6 @@ EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
src\Java.Interop.NamingCustomAttributes\Java.Interop.NamingCustomAttributes.projitems*{58b564a1-570d-4da2-b02d-25bddb1a9f4f}*SharedItemsImports = 5
- src\Java.Interop.NamingCustomAttributes\Java.Interop.NamingCustomAttributes.projitems*{d1295a8f-4f42-461d-a046-564476c10002}*SharedItemsImports = 5
src\Java.Interop.NamingCustomAttributes\Java.Interop.NamingCustomAttributes.projitems*{d18fcf91-8876-48a0-a693-2dc1e7d3d80a}*SharedItemsImports = 5
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -133,10 +122,6 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {D1295A8F-4F42-461D-A046-564476C10002}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {D1295A8F-4F42-461D-A046-564476C10002}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {D1295A8F-4F42-461D-A046-564476C10002}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {D1295A8F-4F42-461D-A046-564476C10002}.Release|Any CPU.Build.0 = Release|Any CPU
{7387E151-48E3-4885-B2CA-A74434A34045}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7387E151-48E3-4885-B2CA-A74434A34045}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7387E151-48E3-4885-B2CA-A74434A34045}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -161,10 +146,6 @@ Global
{AD4468F8-8883-434B-9D4C-E1801BB3B52A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AD4468F8-8883-434B-9D4C-E1801BB3B52A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AD4468F8-8883-434B-9D4C-E1801BB3B52A}.Release|Any CPU.Build.0 = Release|Any CPU
- {B501D075-6183-4E1D-92C9-F7B5002475B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {B501D075-6183-4E1D-92C9-F7B5002475B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {B501D075-6183-4E1D-92C9-F7B5002475B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {B501D075-6183-4E1D-92C9-F7B5002475B1}.Release|Any CPU.Build.0 = Release|Any CPU
{5C0B3562-8DA0-4726-9762-75B9709ED6B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5C0B3562-8DA0-4726-9762-75B9709ED6B7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5C0B3562-8DA0-4726-9762-75B9709ED6B7}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -205,10 +186,6 @@ Global
{82B1DD53-69CA-4A61-B6B1-F06F1525EF4D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{82B1DD53-69CA-4A61-B6B1-F06F1525EF4D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{82B1DD53-69CA-4A61-B6B1-F06F1525EF4D}.Release|Any CPU.Build.0 = Release|Any CPU
- {82F24161-F0CA-44CC-AEC3-885D613605E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {82F24161-F0CA-44CC-AEC3-885D613605E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {82F24161-F0CA-44CC-AEC3-885D613605E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {82F24161-F0CA-44CC-AEC3-885D613605E0}.Release|Any CPU.Build.0 = Release|Any CPU
{DB05D566-0BA0-4935-868D-689E2F03688E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DB05D566-0BA0-4935-868D-689E2F03688E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DB05D566-0BA0-4935-868D-689E2F03688E}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -321,14 +298,6 @@ Global
{CB05E11B-B96F-4179-A4E9-5D6BDE29A8FC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CB05E11B-B96F-4179-A4E9-5D6BDE29A8FC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CB05E11B-B96F-4179-A4E9-5D6BDE29A8FC}.Release|Any CPU.Build.0 = Release|Any CPU
- {1A0262FE-3CDB-4AF2-AAD8-65C59524FE8A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {1A0262FE-3CDB-4AF2-AAD8-65C59524FE8A}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {1A0262FE-3CDB-4AF2-AAD8-65C59524FE8A}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {1A0262FE-3CDB-4AF2-AAD8-65C59524FE8A}.Release|Any CPU.Build.0 = Release|Any CPU
- {211BAA88-66B1-41B2-88B2-530DBD8DF702}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {211BAA88-66B1-41B2-88B2-530DBD8DF702}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {211BAA88-66B1-41B2-88B2-530DBD8DF702}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {211BAA88-66B1-41B2-88B2-530DBD8DF702}.Release|Any CPU.Build.0 = Release|Any CPU
{DA458F90-218B-4FE3-995F-AF4B27895FA2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DA458F90-218B-4FE3-995F-AF4B27895FA2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DA458F90-218B-4FE3-995F-AF4B27895FA2}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -350,14 +319,12 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
- {D1295A8F-4F42-461D-A046-564476C10002} = {C8F58966-94BF-407F-914A-8654F8B8AE3B}
{7387E151-48E3-4885-B2CA-A74434A34045} = {C8F58966-94BF-407F-914A-8654F8B8AE3B}
{38C762AB-8FD1-44DE-9855-26AAE7129DC3} = {C8F58966-94BF-407F-914A-8654F8B8AE3B}
{D14A1B5C-2060-4930-92BE-F7190256C735} = {C8F58966-94BF-407F-914A-8654F8B8AE3B}
{94BD81F7-B06F-4295-9636-F8A3B6BDC762} = {4C173212-371D-45D8-BA83-9226194F48DC}
{BB0AB9F7-0979-41A7-B7A9-877260655F94} = {4C173212-371D-45D8-BA83-9226194F48DC}
{AD4468F8-8883-434B-9D4C-E1801BB3B52A} = {4C173212-371D-45D8-BA83-9226194F48DC}
- {B501D075-6183-4E1D-92C9-F7B5002475B1} = {4C173212-371D-45D8-BA83-9226194F48DC}
{5C0B3562-8DA0-4726-9762-75B9709ED6B7} = {0998E45F-8BCE-4791-A944-962CD54E2D80}
{5887B410-D448-4257-A46B-EAC03C80BE93} = {0998E45F-8BCE-4791-A944-962CD54E2D80}
{B17475BC-45A2-47A3-B8FC-62F3A0959EE0} = {0998E45F-8BCE-4791-A944-962CD54E2D80}
@@ -368,7 +335,6 @@ Global
{6970466B-F6D1-417A-8A27-4FED8555EBD0} = {271C9F30-F679-4793-942B-0D9527CB3E2F}
{04E28441-36FF-4964-ADD7-EFBB47CCE406} = {271C9F30-F679-4793-942B-0D9527CB3E2F}
{82B1DD53-69CA-4A61-B6B1-F06F1525EF4D} = {271C9F30-F679-4793-942B-0D9527CB3E2F}
- {82F24161-F0CA-44CC-AEC3-885D613605E0} = {271C9F30-F679-4793-942B-0D9527CB3E2F}
{DB05D566-0BA0-4935-868D-689E2F03688E} = {271C9F30-F679-4793-942B-0D9527CB3E2F}
{C9FA4492-DEB0-4932-A6B8-E2C4E0581692} = {271C9F30-F679-4793-942B-0D9527CB3E2F}
{891F2E04-5614-4A26-A78F-3778025ECF43} = {271C9F30-F679-4793-942B-0D9527CB3E2F}
@@ -397,8 +363,6 @@ Global
{11942DE9-AEC2-4B95-87AB-CA707C37643D} = {271C9F30-F679-4793-942B-0D9527CB3E2F}
{30DCECA5-16FD-4FD0-883C-E5E83B11565D} = {0998E45F-8BCE-4791-A944-962CD54E2D80}
{CB05E11B-B96F-4179-A4E9-5D6BDE29A8FC} = {271C9F30-F679-4793-942B-0D9527CB3E2F}
- {1A0262FE-3CDB-4AF2-AAD8-65C59524FE8A} = {0998E45F-8BCE-4791-A944-962CD54E2D80}
- {211BAA88-66B1-41B2-88B2-530DBD8DF702} = {271C9F30-F679-4793-942B-0D9527CB3E2F}
{DA458F90-218B-4FE3-995F-AF4B27895FA2} = {0998E45F-8BCE-4791-A944-962CD54E2D80}
{6BC04C7F-949E-4F93-BF1F-E3B1DF0B888D} = {271C9F30-F679-4793-942B-0D9527CB3E2F}
{8DB3842B-73D7-491C-96F9-EBC863E2C917} = {D5A93398-AEB1-49F3-89DC-3904A47DB0C7}
diff --git a/Makefile b/Makefile
index 8f31778fd..99b00c2c2 100644
--- a/Makefile
+++ b/Makefile
@@ -23,7 +23,6 @@ NET_SUFFIX = -net7.0
TESTS = \
bin/Test$(CONFIGURATION)/Java.Interop-Tests.dll \
bin/Test$(CONFIGURATION)/Java.Interop.Dynamic-Tests.dll \
- bin/Test$(CONFIGURATION)/Java.Interop.Export-Tests.dll \
bin/Test$(CONFIGURATION)/Java.Interop.Tools.JavaCallableWrappers-Tests.dll \
bin/Test$(CONFIGURATION)/Java.Interop.Tools.JavaSource-Tests.dll \
bin/Test$(CONFIGURATION)/logcat-parse-Tests.dll \
@@ -154,31 +153,6 @@ JRE_DLL_CONFIG=bin/$(CONFIGURATION)/Java.Runtime.Environment.dll.config
$(JRE_DLL_CONFIG): src/Java.Runtime.Environment/Java.Runtime.Environment.csproj
$(MSBUILD) $(MSBUILD_FLAGS) $<
-define run-jnimarshalmethod-gen
- MONO_TRACE_LISTENER=Console.Out \
- dotnet bin/$(CONFIGURATION)$(NET_SUFFIX)/jnimarshalmethod-gen.dll $(2) $(1)
-endef
-
-# want: /usr/local/share/dotnet/shared/Microsoft.NETCore.App/7.0.0
-# have: Microsoft.NETCore.App 7.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
-# use: shell pipeline!
-SYSTEM_NET_ASSEMBLIES_PATH := $(shell dotnet --list-runtimes | grep ^Microsoft.NETCore.App | tail -1 | sed -E 's,^Microsoft.NETCore.App ([^ ]+) \[([^]]+)\]$$,\2/\1,g' )
-
-run-test-jnimarshal: bin/Test$(CONFIGURATION)$(NET_SUFFIX)/Java.Interop.Export-Tests.dll bin/Test$(CONFIGURATION)$(NET_SUFFIX)/$(JAVA_INTEROP_LIB) bin/ilverify
- mkdir -p test-jni-output
- # Do we run w/o error?
- $(call run-jnimarshalmethod-gen,"$<", -v -v -o test-jni-output --keeptemp)
- (test -f test-jni-output/$(notdir $<) ) || { echo "jnimarshalmethod-gen did not create the expected assemblies in the test-jni-output directory"; exit 1; }
- # Is output valid?
- ikdasm test-jni-output/Java.Interop.Export-Tests.dll || { echo "output can not be processed by ikdasm"; exit 1; }
- bin/ilverify test-jni-output/Java.Interop.Export-Tests.dll \
- --tokens --system-module System.Private.CoreLib -r '$(dir $<)/*.dll' \
- -r '$(SYSTEM_NET_ASSEMBLIES_PATH)/*.dll' || { echo "ilverify found issues"; exit 1; }
- # replace "original" assembly
- $(call run-jnimarshalmethod-gen,"$<")
- # make sure tests still pass
- dotnet test $<
-
bin/Test$(CONFIGURATION)/generator.exe: bin/$(CONFIGURATION)/generator.exe
cp $<* `dirname "$@"`
diff --git a/build-tools/automation/templates/core-tests.yaml b/build-tools/automation/templates/core-tests.yaml
index 21764643a..ba7393dec 100644
--- a/build-tools/automation/templates/core-tests.yaml
+++ b/build-tools/automation/templates/core-tests.yaml
@@ -69,31 +69,6 @@ steps:
condition: eq('${{ parameters.runNativeTests }}', 'true')
retryCount: 1
-- template: run-dotnet-test.yaml
- parameters:
- testRunTitle: Java.Interop.Export (${{ parameters.platformName }})
- testAssemblyName: Java.Interop.Export-Tests
- condition: or(eq('${{ parameters.runNativeDotnetTests }}', 'true'), eq('${{ parameters.runNativeTests }}', 'true'))
- retryCount: 1
-
-- task: DotNetCoreCLI@2
- displayName: 'jnimarshalmethod-gen Java.Interop.Export-Tests.dll'
- condition: or(eq('${{ parameters.runNativeDotnetTests }}', 'true'), eq('${{ parameters.runNativeTests }}', 'true'))
- inputs:
- command: custom
- custom: bin/$(Build.Configuration)$(NetCoreTargetFrameworkPathSuffix)/jnimarshalmethod-gen.dll
- arguments: bin/Test$(Build.Configuration)$(NetCoreTargetFrameworkPathSuffix)/Java.Interop.Export-Tests.dll -v -v --keeptemp -o bin/Test$(Build.Configuration)$(NetCoreTargetFrameworkPathSuffix)
- continueOnError: true
- retryCountOnTaskFailure: 1
-
-- template: run-dotnet-test.yaml
- parameters:
- testRunTitle: Java.Interop.Export (jnimarshalmethod-gen + ${{ parameters.platformName }})
- testAssemblyName: Java.Interop.Export-Tests
- trxSuffix: -jnimarshalmethod
- condition: or(eq('${{ parameters.runNativeDotnetTests }}', 'true'), eq('${{ parameters.runNativeTests }}', 'true'))
- retryCount: 1
-
- template: run-dotnet-test.yaml
parameters:
testRunTitle: Java.Interop-Performance ($(DotNetTargetFramework) - ${{ parameters.platformName }})
@@ -109,24 +84,6 @@ steps:
condition: or(eq('${{ parameters.runNativeDotnetTests }}', 'true'), eq('${{ parameters.runNativeTests }}', 'true'))
retryCount: 1
-- task: DotNetCoreCLI@2
- displayName: 'jnimarshalmethod-gen Java.Base-Tests.dll'
- condition: or(eq('${{ parameters.runNativeDotnetTests }}', 'true'), eq('${{ parameters.runNativeTests }}', 'true'))
- inputs:
- command: custom
- custom: bin/$(Build.Configuration)$(NetCoreTargetFrameworkPathSuffix)/jnimarshalmethod-gen.dll
- arguments: bin/Test$(Build.Configuration)$(NetCoreTargetFrameworkPathSuffix)/Java.Base-Tests.dll -v -v --keeptemp
- continueOnError: true
- retryCountOnTaskFailure: 1
-
-- template: run-dotnet-test.yaml
- parameters:
- testRunTitle: Java.Base ($(DotNetTargetFramework) - ${{ parameters.platformName }})
- testAssemblyName: Java.Base-Tests
- trxSuffix: -jnimarshalmethod
- condition: or(eq('${{ parameters.runNativeDotnetTests }}', 'true'), eq('${{ parameters.runNativeTests }}', 'true'))
- retryCount: 1
-
- task: DotNetCoreCLI@2
displayName: 'Tests: java-source-utils'
inputs:
diff --git a/samples/Hello-NativeAOTFromAndroid/Hello-NativeAOTFromAndroid.csproj b/samples/Hello-NativeAOTFromAndroid/Hello-NativeAOTFromAndroid.csproj
index 3b9bb1d03..5923127ff 100644
--- a/samples/Hello-NativeAOTFromAndroid/Hello-NativeAOTFromAndroid.csproj
+++ b/samples/Hello-NativeAOTFromAndroid/Hello-NativeAOTFromAndroid.csproj
@@ -32,15 +32,10 @@
-
-
-
-
-
- <_JnimmRefAsmDirs Include="@(RuntimePackAsset->'%(RootDir)%(Directory).'->Distinct())" />
-
-
- <_JnimarshalmethodGen>"$(UtilityOutputFullPath)/jnimarshalmethod-gen.dll"
- <_Verbosity>-v -v --keeptemp
- <_Libpath>-L "$(TargetDir)" @(_JnimmRefAsmDirs->'-L "%(Identity)"', ' ')
-
-
-
-
-
-
-
-
-
-
-
<_BuildAppApkInput Include="$(MSBuildThisFileFullPath)" />
<_BuildAppApkInput Include="app\src\main\java\**\*.java" />
@@ -181,7 +157,6 @@
<_AfterBuildDependsOnTargets>
_CreateJavaCallableWrappers;
- _AddMarshalMethods;
diff --git a/samples/Hello-NativeAOTFromAndroid/JavaInteropRuntime.cs b/samples/Hello-NativeAOTFromAndroid/JavaInteropRuntime.cs
index 74d7e21f8..f6595cdc1 100644
--- a/samples/Hello-NativeAOTFromAndroid/JavaInteropRuntime.cs
+++ b/samples/Hello-NativeAOTFromAndroid/JavaInteropRuntime.cs
@@ -38,7 +38,6 @@ static void init (IntPtr jnienv, IntPtr klass)
var options = new JreRuntimeOptions {
EnvironmentPointer = jnienv,
TypeManager = new NativeAotTypeManager (),
- UseMarshalMemberBuilder = false,
JniGlobalReferenceLogWriter = new LogcatTextWriter (AndroidLogLevel.Debug, "NativeAot:GREF"),
JniLocalReferenceLogWriter = new LogcatTextWriter (AndroidLogLevel.Debug, "NativeAot:LREF"),
};
diff --git a/samples/Hello-NativeAOTFromJNI/Hello-NativeAOTFromJNI.csproj b/samples/Hello-NativeAOTFromJNI/Hello-NativeAOTFromJNI.csproj
index 53822ff34..bf970f8ae 100644
--- a/samples/Hello-NativeAOTFromJNI/Hello-NativeAOTFromJNI.csproj
+++ b/samples/Hello-NativeAOTFromJNI/Hello-NativeAOTFromJNI.csproj
@@ -21,15 +21,10 @@
-
-
diff --git a/samples/Hello-NativeAOTFromJNI/Hello-NativeAOTFromJNI.targets b/samples/Hello-NativeAOTFromJNI/Hello-NativeAOTFromJNI.targets
index 695c22c18..e61081ce1 100644
--- a/samples/Hello-NativeAOTFromJNI/Hello-NativeAOTFromJNI.targets
+++ b/samples/Hello-NativeAOTFromJNI/Hello-NativeAOTFromJNI.targets
@@ -25,30 +25,6 @@
-
-
-
- <_JnimmRefAsmDirs Include="@(RuntimePackAsset->'%(RootDir)%(Directory).'->Distinct())" />
-
-
- <_JnimarshalmethodGen>"$(UtilityOutputFullPath)/jnimarshalmethod-gen.dll"
- <_Verbosity>-v -v --keeptemp
- <_Libpath>-L "$(TargetDir)" @(_JnimmRefAsmDirs->'-L "%(Identity)"', ' ')
-
-
-
-
-
-
-
-
-
-
-
(ref r_self, JniObjectReferenceOptions.CopyAndDoNotRegister);
+ try {
+ var result = self!.GetString ();
+ var r = result.PeerReference.NewLocalRef ();
+ return JniEnvironment.References.NewReturnToJniRef (r);
+ } finally {
+ self?.DisposeUnlessReferenced ();
+ }
+ }
+
+ [JniAddNativeMethodRegistration]
+ static void RegisterNativeMembers (JniNativeMethodRegistrationArguments args)
+ {
+ args.AddRegistrations (new [] {
+ new JniNativeMethodRegistration ("n_GetString", "()Ljava/lang/String;", new _JniMarshal_PP_L (n_GetString)),
+ });
+ }
}
diff --git a/src/Java.Interop.Export/Java.Interop.Export.csproj b/src/Java.Interop.Export/Java.Interop.Export.csproj
deleted file mode 100644
index 2ac22300d..000000000
--- a/src/Java.Interop.Export/Java.Interop.Export.csproj
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
- $(DotNetTargetFramework)
- enable
- true
- ..\..\product.snk
-
-
-
-
-
- $(ToolOutputFullPath)
- $(JICoreLibVersion)
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Java.Interop.Export/Java.Interop/MarshalMemberBuilder.cs b/src/Java.Interop.Export/Java.Interop/MarshalMemberBuilder.cs
deleted file mode 100644
index 159db9fed..000000000
--- a/src/Java.Interop.Export/Java.Interop/MarshalMemberBuilder.cs
+++ /dev/null
@@ -1,545 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Diagnostics.CodeAnalysis;
-using System.Linq;
-using System.Linq.Expressions;
-using System.Reflection;
-using System.Reflection.Emit;
-using System.Text;
-
-using Java.Interop.Expressions;
-
-namespace Java.Interop {
-
- [RequiresDynamicCode (ExpressionRequiresUnreferencedCode)]
- [RequiresUnreferencedCode (ExpressionRequiresUnreferencedCode)]
- public class MarshalMemberBuilder : JniRuntime.JniMarshalMemberBuilder
- {
- internal const string ExpressionRequiresUnreferencedCode = "System.Linq.Expression usage may trim away required code.";
-
- public MarshalMemberBuilder ()
- {
- }
-
- public MarshalMemberBuilder (JniRuntime runtime)
- {
- if (runtime == null)
- throw new ArgumentNullException (nameof (runtime));
-
- OnSetRuntime (runtime);
- }
-
- public override LambdaExpression CreateMarshalToManagedExpression (MethodInfo method)
- {
- if (method == null)
- throw new ArgumentNullException (nameof (method));
-
- return CreateMarshalToManagedExpression (method, null, method.DeclaringType);
- }
-
- public override IEnumerable GetExportedMemberRegistrations (Type declaringType)
- {
- if (declaringType == null)
- throw new ArgumentNullException ("declaringType");
- return CreateExportedMemberRegistrationIterator (declaringType);
- }
-
- IEnumerable CreateExportedMemberRegistrationIterator (Type declaringType)
- {
- foreach (var method in declaringType.GetTypeInfo ().DeclaredMethods) {
- var exports = (JavaCallableAttribute[]) method.GetCustomAttributes (typeof(JavaCallableAttribute), inherit:false);
- if (exports == null || exports.Length == 0)
- continue;
- var export = exports [0];
- yield return CreateMarshalToManagedMethodRegistration (export, method, declaringType);
- }
- }
-
- public JniNativeMethodRegistration CreateMarshalToManagedMethodRegistration (JavaCallableAttribute export, MethodInfo method, Type? type = null)
- {
- if (export == null)
- throw new ArgumentNullException ("export");
- if (method == null)
- throw new ArgumentNullException ("method");
-
- string signature = GetJniMethodSignature (export, method);
- return new JniNativeMethodRegistration () {
- Name = GetJniMethodName (export, method),
- Signature = signature,
- Marshaler = CreateJniMethodMarshaler (method, export, type),
- };
- }
-
- string GetJniMethodName (JavaCallableAttribute export, MethodInfo method)
- {
- return "n_" + method.Name;
- }
-
- public string GetJniMethodSignature (JavaCallableAttribute export, MethodInfo method)
- {
- if (export == null)
- throw new ArgumentNullException ("export");
- if (method == null)
- throw new ArgumentNullException ("method");
-
- if (export.Signature != null)
- return export.Signature;
-
- return export.Signature = GetJniMethodSignature (method);
- }
-
- Delegate CreateJniMethodMarshaler (MethodInfo method, JavaCallableAttribute? export, Type? type)
- {
- var e = CreateMarshalToManagedExpression (method, export, type);
- return e.Compile ();
- }
-
- public LambdaExpression CreateMarshalToManagedExpression (MethodInfo method, JavaCallableAttribute? callable, Type? type = null)
- {
- if (method == null)
- throw new ArgumentNullException ("method");
- type = type ?? method.DeclaringType;
-
- var methodParameters = method.GetParameters ();
-
- CheckMarshalTypesMatch (method, callable?.Signature, methodParameters);
-
- bool direct = IsDirectMethod (methodParameters);
-
- var jnienv = Expression.Parameter (typeof (IntPtr), direct ? methodParameters [0].Name : "__jnienv");
- var context = Expression.Parameter (typeof (IntPtr), direct ? methodParameters [1].Name : (method.IsStatic ? "__class" : "__this"));
-
- var envp = Expression.Variable (typeof (JniTransition), "__envp");
- var jvm = Expression.Variable (typeof (JniRuntime), "__jvm");
- var vm = Expression.Variable (typeof (JniRuntime.JniValueManager), "__vm");
- var envpVars = new List () {
- envp,
- jvm,
- };
-
- int peerableParametersCount = 0;
- for (int i = 0; i < methodParameters.Length; ++i) {
- var marshaler = GetParameterMarshaler (methodParameters [i]);
-
- if (typeof (IJavaPeerable).GetTypeInfo ().IsAssignableFrom (methodParameters [i].ParameterType.GetTypeInfo ()))
- peerableParametersCount ++;
- }
-
- bool useVmVariable = (!method.IsStatic || peerableParametersCount > 0) && !direct;
- if (useVmVariable)
- envpVars.Add (vm);
-
- var envpBody = new List () {
- Expression.Assign (envp, CreateJniTransition (jnienv)),
- };
-
- var waitForGCBridge = typeof(JniRuntime.JniValueManager)
- .GetRuntimeMethod (nameof (JniRuntime.JniValueManager.WaitForGCBridgeProcessing), new Type [0]) ??
- throw new NotSupportedException ("Could not find JniRuntime.JniValueManager.WaitForGCBridgeProcessing()");
-
- var marshalBody = new List () {
- Expression.Assign (jvm, GetRuntime ()),
- };
-
- if (useVmVariable) {
- marshalBody.Add (Expression.Assign (vm, Expression.Property (jvm, "ValueManager")));
- marshalBody.Add (Expression.Call (vm, waitForGCBridge));
- } else
- marshalBody.Add (Expression.Call (Expression.Property (jvm, "ValueManager"), waitForGCBridge));
-
- Expression? self = null;
- var marshalerContext = new JniValueMarshalerContext (jvm, useVmVariable ? vm : null);
- if (!method.IsStatic) {
- var selfMarshaler = Runtime.ValueManager.GetValueMarshaler (type!);
- self = selfMarshaler.CreateParameterToManagedExpression (marshalerContext, context, 0, type);
- }
-
- var marshalParameters = new List (methodParameters.Length);
- var invokeParameters = new List (methodParameters.Length);
- for (int i = 0; i < methodParameters.Length; ++i) {
- var marshaler = GetParameterMarshaler (methodParameters [i]);
- ParameterExpression np;
- if (i > 1 || !direct)
- np = Expression.Parameter (marshaler.MarshalType, methodParameters [i].Name);
- else {
- if (i == 0)
- np = jnienv;
- else if (i == 1)
- np = context;
- else
- throw new InvalidOperationException ("Should not be reached.");
- }
- var p = marshaler.CreateParameterToManagedExpression (marshalerContext, np, methodParameters [i].Attributes, methodParameters [i].ParameterType);
- marshalParameters.Add (np);
- invokeParameters.Add (p);
- }
-
- marshalBody.AddRange (marshalerContext.CreationStatements);
-
- Expression invoke = method.IsStatic
- ? Expression.Call (method, invokeParameters)
- : Expression.Call (self, method, invokeParameters);
- Expression? ret = null;
- if (method.ReturnType == typeof (void)) {
- envpVars.AddRange (marshalerContext.LocalVariables);
-
- marshalBody.Add (invoke);
- envpBody.Add (
- Expression.TryCatchFinally (
- Expression.Block (marshalBody),
- CreateDisposeJniEnvironment (envp, marshalerContext.CleanupStatements),
- CreateMarshalException (envp, jvm, null)));
- } else {
- var rmarshaler = GetParameterMarshaler (method.ReturnParameter);
- var jniRType = rmarshaler.MarshalType;
- var exit = Expression.Label (jniRType, "__exit");
- var mret = Expression.Variable (method.ReturnType, "__mret");
- envpVars.Add (mret);
- marshalBody.Add (Expression.Assign (mret, invoke));
- marshalerContext.CreationStatements.Clear ();
- ret = rmarshaler.CreateReturnValueFromManagedExpression (marshalerContext, mret);
- marshalBody.AddRange (marshalerContext.CreationStatements);
- marshalBody.Add (Expression.Return (exit, ret));
-
- envpVars.AddRange (marshalerContext.LocalVariables);
-
- envpBody.Add (
- Expression.TryCatchFinally (
- Expression.Block (marshalBody),
- CreateDisposeJniEnvironment (envp, marshalerContext.CleanupStatements),
- CreateMarshalException (envp, jvm, exit)));
-
- envpBody.Add (Expression.Label (exit, Expression.Default (jniRType)));
- }
-
- var funcTypeParams = new List ();
- var bodyParams = new List ();
- if (!direct) {
- funcTypeParams.Add (typeof (IntPtr));
- funcTypeParams.Add (typeof (IntPtr));
- bodyParams.Add (jnienv);
- bodyParams.Add (context);
- }
- foreach (var p in marshalParameters)
- funcTypeParams.Add (p.Type);
- var marshalerType = GetMarshalerType (ret?.Type, funcTypeParams, method.DeclaringType);
-
- bodyParams.AddRange (marshalParameters);
- var body = Expression.Block (envpVars, envpBody);
-
- return marshalerType == null
- ? Expression.Lambda (body, bodyParams)
- : Expression.Lambda (marshalerType, body, bodyParams);
- }
-
- // Keep in sync with ExpressionAssemblyBuilder.GetMarshalMethodDelegateType()
- static Type? GetMarshalerType (Type? returnType, List funcTypeParams, Type? declaringType)
- {
- // Too many parameters; does a `_JniMarshal_*` type exist in the type's declaring assembly?
- funcTypeParams.RemoveRange (0, 2);
- var marshalDelegateName = new StringBuilder ();
- marshalDelegateName.Append ("_JniMarshal_PP");
- foreach (var paramType in funcTypeParams) {
- marshalDelegateName.Append (GetJniMarshalDelegateParameterIdentifier (paramType));
- }
- marshalDelegateName.Append ("_");
- if (returnType == null) {
- marshalDelegateName.Append ("V");
- } else {
- marshalDelegateName.Append (GetJniMarshalDelegateParameterIdentifier (returnType));
- }
-
- Type? marshalDelegateType = declaringType?.Assembly.GetType (marshalDelegateName.ToString (), throwOnError: false);
- if (marshalDelegateType != null) {
- return marshalDelegateType;
- }
-
-#if !NET
- // Punt?; System.Linq.Expressions will automagically produce the needed delegate type.
- // Unfortunately, this won't work with jnimarshalmethod-gen.exe.
- return marshalDelegateType;
-#else // NET
- return CreateMarshalDelegateType (marshalDelegateName.ToString (), returnType, funcTypeParams);
-#endif // NET
- }
-
-#if NET
- static object ab_lock = new object ();
- static AssemblyBuilder? assemblyBuilder;
- static ModuleBuilder? moduleBuilder;
- static Type[]? DelegateCtorSignature;
- static Dictionary? marshalDelegateTypes;
-
- static Type? CreateMarshalDelegateType (string name, Type? returnType, List funcTypeParams)
- {
- lock (ab_lock) {
- if (assemblyBuilder == null) {
- var aname = new AssemblyName ("jni-marshal-method-delegates");
- assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly (aname, AssemblyBuilderAccess.Run);
- moduleBuilder = assemblyBuilder.DefineDynamicModule (aname.Name!);
-
- DelegateCtorSignature = new Type[] {
- typeof (object),
- typeof (IntPtr)
- };
- marshalDelegateTypes = new (StringComparer.Ordinal);
- }
- if (marshalDelegateTypes!.TryGetValue (name, out var type)) {
- return type;
- }
- funcTypeParams.Insert (0, typeof (IntPtr));
- funcTypeParams.Insert (0, typeof (IntPtr));
- var typeBuilder = moduleBuilder!.DefineType (
- name,
- TypeAttributes.Class | TypeAttributes.Public | TypeAttributes.Sealed | TypeAttributes.AnsiClass | TypeAttributes.AutoClass,
- typeof (MulticastDelegate)
- );
-
- const MethodAttributes CtorAttributes = MethodAttributes.RTSpecialName | MethodAttributes.HideBySig | MethodAttributes.Public;
- const MethodImplAttributes ImplAttributes = MethodImplAttributes.Runtime | MethodImplAttributes.Managed;
- const MethodAttributes InvokeAttributes = MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.NewSlot | MethodAttributes.Virtual;
-
- typeBuilder.DefineConstructor (CtorAttributes, CallingConventions.Standard, DelegateCtorSignature)
- .SetImplementationFlags (ImplAttributes);
- typeBuilder.DefineMethod ("Invoke", InvokeAttributes, returnType, funcTypeParams.ToArray ())
- .SetImplementationFlags (ImplAttributes);
- var marshalDelType = typeBuilder.CreateTypeInfo ();
- marshalDelegateTypes.Add (name, marshalDelType);
- return marshalDelType;
- }
- }
-#endif // NET
-
- static char GetJniMarshalDelegateParameterIdentifier (Type type)
- {
- if (type == typeof (bool)) return 'Z';
- if (type == typeof (byte)) return 'B';
- if (type == typeof (sbyte)) return 'B';
- if (type == typeof (char)) return 'C';
- if (type == typeof (short)) return 'S';
- if (type == typeof (ushort)) return 's';
- if (type == typeof (int)) return 'I';
- if (type == typeof (uint)) return 'i';
- if (type == typeof (long)) return 'J';
- if (type == typeof (ulong)) return 'j';
- if (type == typeof (float)) return 'F';
- if (type == typeof (double)) return 'D';
- if (type == typeof (void)) return 'V';
- return 'L';
- }
-
- void CheckMarshalTypesMatch (MethodInfo method, string? signature, ParameterInfo[] methodParameters)
- {
- if (signature == null)
- return;
-
- var mptypes = JniSignature.GetMarshalParameterTypes (signature).ToList ();
- int rpcount = methodParameters.Length;
- int len = Math.Min (methodParameters.Length, mptypes.Count);
- int start = 0;
- if (IsDirectMethod (methodParameters)) {
- start += 2;
- rpcount -= 2;
- }
- for (int i = start; i < len; ++i) {
- var vm = GetParameterMarshaler (methodParameters [i]);
- var jni = vm.MarshalType;
- if (mptypes [i] != jni)
- throw new ArgumentException (
- $"JNI parameter type mismatch. Type `{jni}` != `{mptypes [i]}` at index {i} in `{signature}`.",
- "signature");
- }
-
- if (mptypes.Count != rpcount)
- throw new ArgumentException (
- string.Format ("JNI parametr count mismatch: signature contains {0} parameters, method contains {1}.",
- mptypes.Count, methodParameters.Length),
- nameof (signature));
-
- var jrinfo = JniSignature.GetMarshalReturnType (signature);
- var mrvm = GetParameterMarshaler (method.ReturnParameter);
- var mrinfo = mrvm.MarshalType;
- if (mrinfo != jrinfo)
- throw new ArgumentException (
- string.Format ("JNI return type mismatch. Type '{0}' != '{1}'.", jrinfo, mrinfo),
- nameof (signature));
- }
-
- static ConstructorInfo JniTransitionConstructor =
- (from c in typeof (JniTransition).GetTypeInfo ().DeclaredConstructors
- let p = c.GetParameters ()
- where p.Length == 1 && p [0].ParameterType == typeof (IntPtr)
- select c)
- .First ();
-
- static Expression CreateJniTransition (ParameterExpression jnienv)
- {
- return Expression.New (
- JniTransitionConstructor,
- jnienv);
- }
-
- static readonly MethodInfo JniRuntime_ExceptionShouldTransitionToJni =
- typeof(JniRuntime).GetRuntimeMethod ("ExceptionShouldTransitionToJni", new[] { typeof (Exception) }) ??
- throw new NotSupportedException ("Could not find `JniRuntime.ExceptionShouldTransitionToJni()`");
- static readonly MethodInfo JniTransition_SetPendingException =
- ((Action) (new JniTransition ().SetPendingException)).Method;
-
- static CatchBlock CreateMarshalException (ParameterExpression envp, ParameterExpression jvm, LabelTarget? exit)
- {
- var ex = Expression.Variable (typeof (Exception), "__e");
- var body = new List () {
- Expression.Call (envp, JniTransition_SetPendingException, ex),
- };
- if (exit != null) {
- body.Add (Expression.Return (exit, Expression.Default (exit.Type)));
- }
- var filter = Expression.Call (jvm, JniRuntime_ExceptionShouldTransitionToJni, ex);
- return Expression.Catch (ex, Expression.Block (body), filter);
- }
-
- static readonly MethodInfo JniTransition_Dispose = ((Action) (new JniTransition ().Dispose)).Method;
-
- static Expression CreateDisposeJniEnvironment (ParameterExpression envp, IList cleanup)
- {
- var disposeTransition = Expression.Call (envp, JniTransition_Dispose);
- return Expression.Block (
- cleanup.Reverse ().Concat (new[]{ disposeTransition }));;
- }
-
- static Expression GetRuntime ()
- {
- return Expression.Property (null, typeof (JniEnvironment), "Runtime");
- }
-
- static MethodInfo FormatterServices_GetUninitializedObject =
-#if NETCOREAPP
- ((Func) System.Runtime.CompilerServices.RuntimeHelpers.GetUninitializedObject)
-#else // !NETCOREAPP
- ((Func) System.Runtime.Serialization.FormatterServices.GetUninitializedObject)
-#endif // NETCOREAPP
- .Method;
- static MethodInfo IJavaPeerable_SetPeerReference =
- typeof (IJavaPeerable).GetRuntimeMethod ("SetPeerReference", new[]{typeof (JniObjectReference)}) ??
- throw new NotSupportedException ("Could not find IJavaPeerable.SetPeerReference()!");
-
- public override Expression> CreateConstructActivationPeerExpression (ConstructorInfo constructor)
- {
- if (constructor == null)
- throw new ArgumentNullException (nameof (constructor));
-
- Func