Skip to content

Commit fd00686

Browse files
committed
Collect overridden Java methods in JCW
Marshal methods generator in Xamarin.Android needs to know which Java methods in which types are overridden by the application. Package name, method name and signature are all require to generate correct name of the native symbol which will be found by JNI at the run time.
1 parent 3fcce74 commit fd00686

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/Java.Interop.Tools.JavaCallableWrappers/Java.Interop.Tools.JavaCallableWrappers/JavaCallableWrapperGenerator.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public string GetJavaAccess ()
5959
List<Signature> methods = new List<Signature> ();
6060
List<Signature> ctors = new List<Signature> ();
6161
List<JavaCallableWrapperGenerator> children;
62+
List<string> overriddenMethods;
6263
readonly IMetadataResolver cache;
6364

6465
[Obsolete ("Use the TypeDefinitionCache overload for better performance.")]
@@ -80,6 +81,7 @@ public JavaCallableWrapperGenerator (TypeDefinition type, Action<string, object[
8081
}
8182
}
8283

84+
public List<string> OverriddenMethods => overriddenMethods;
8385
public string ApplicationJavaClass { get; set; }
8486
public JavaPeerStyle CodeGenerationTarget { get; set; }
8587

@@ -497,6 +499,7 @@ string GetManagedParameters (MethodDefinition ctor, string outerType)
497499

498500
public void Generate (TextWriter writer)
499501
{
502+
overriddenMethods = new List<string> ();
500503
if (!string.IsNullOrEmpty (package)) {
501504
writer.WriteLine ("package " + package + ";");
502505
writer.WriteLine ();
@@ -530,6 +533,17 @@ public void Generate (TextWriter writer)
530533
}
531534

532535
GenerateFooter (writer);
536+
537+
string javaTypeName = $"{package}.{name}";
538+
AddOverridenMethods (methods);
539+
AddOverridenMethods (ctors);
540+
541+
void AddOverridenMethods (List<Signature> list)
542+
{
543+
foreach (Signature sig in list) {
544+
overriddenMethods.Add ($"{javaTypeName}:{sig.Method}");
545+
}
546+
}
533547
}
534548

535549
public void Generate (string outputPath)
@@ -958,5 +972,3 @@ public string GetDestinationPath (string outputPath)
958972
}
959973
}
960974
}
961-
962-

0 commit comments

Comments
 (0)