Skip to content

Commit

Permalink
Test JI #1174.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpobst committed Feb 16, 2024
1 parent e987ac4 commit 7e6ec67
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion external/Java.Interop
24 changes: 17 additions & 7 deletions src/Xamarin.Android.Build.Tasks/Tasks/GenerateJavaStubs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

using Xamarin.Android.Tools;
using Microsoft.Android.Build.Tasks;
using Java.Interop.Tools.JavaCallableWrappers.Adapters;

namespace Xamarin.Android.Tasks
{
Expand Down Expand Up @@ -473,23 +474,32 @@ bool CreateJavaSources (IEnumerable<JavaType> newJavaTypes, TypeDefinitionCache

using (var writer = MemoryStreamPool.Shared.CreateStreamWriter ()) {
try {
var jti = new JavaCallableWrapperGenerator (t, Log.LogWarning, cache, classifier) {
GenerateOnCreateOverrides = generateOnCreateOverrides,
ApplicationJavaClass = ApplicationJavaClass,
MonoRuntimeInitialization = monoInit,
var reader_options = new CallableWrapperReaderOptions {
DefaultApplicationJavaClass = ApplicationJavaClass,
DefaultGenerateOnCreateOverrides = generateOnCreateOverrides,
DefaultMonoRuntimeInitialization = monoInit,
MethodClassifier = classifier,
};

jti.Generate (writer);
var jcw_type = CecilImporter.CreateType (t, cache, reader_options);

var writer_options = new CallableWrapperWriterOptions {
CodeGenerationTarget = JavaPeerStyle.XAJavaInterop1
};

jcw_type.Generate (writer, writer_options);

if (useMarshalMethods) {
if (classifier.FoundDynamicallyRegisteredMethods (t)) {
Log.LogWarning ($"Type '{t.GetAssemblyQualifiedName (cache)}' will register some of its Java override methods dynamically. This may adversely affect runtime performance. See preceding warnings for names of dynamically registered methods.");
}
}

writer.Flush ();

var path = jti.GetDestinationPath (outputPath);
var path = jcw_type.GetDestinationPath (outputPath);
Files.CopyIfStreamChanged (writer.BaseStream, path);
if (jti.HasExport && !hasExportReference)
if (jcw_type.HasExport && !hasExportReference)
Diagnostic.Error (4210, Properties.Resources.XA4210);
} catch (XamarinAndroidException xae) {
ok = false;
Expand Down

0 comments on commit 7e6ec67

Please sign in to comment.