Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ void AddNestedTypes (TypeDefinition type)
return d;
})
.Where (d => GetRegisterAttributes (d).Any ())
.SelectMany (d => d.Methods)) {
.SelectMany (d => d.Methods)
.Where (m => !m.IsStatic)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just thought of an issue with this, for which we'll need to add a unit test for: it is perfectly valid to put [Export] on static methods. Thus, as you feared, this "exclude static methods" check is not strict enough. Perhaps it would be enough to simply exclude static methods which lack [Export]?

diff --git a/tests/Java.Interop.Tools.JavaCallableWrappers-Tests/Java.Interop.Tools.JavaCallableWrappers/JavaCallableWrapperGeneratorTests.cs b/tests/Java.Interop.Tools.JavaCallableWrappers-Tests/Java.Interop.Tools.JavaCallableWrappers/JavaCallableWrapperGeneratorTests.cs
index 186409b4..fe6b4081 100644
--- a/tests/Java.Interop.Tools.JavaCallableWrappers-Tests/Java.Interop.Tools.JavaCallableWrappers/JavaCallableWrapperGeneratorTests.cs
+++ b/tests/Java.Interop.Tools.JavaCallableWrappers-Tests/Java.Interop.Tools.JavaCallableWrappers/JavaCallableWrapperGeneratorTests.cs
@@ -189,6 +189,7 @@ public class ExportsMembers
 		__md_methods = 
 			""n_GetInstance:()Lcrc64197ae30a36756915/ExportsMembers;:__export__\n"" +
 			""n_GetValue:()Ljava/lang/String;:__export__\n"" +
+			""n_staticMethodNotMangled:()V:__export__\n"" +
 			""n_methodNamesNotMangled:()V:__export__\n"" +
 			""n_CompletelyDifferentName:(Ljava/lang/String;I)Ljava/lang/String;:__export__\n"" +
 			""n_methodThatThrows:()V:__export__\n"" +
@@ -218,6 +219,14 @@ public class ExportsMembers
 	private native java.lang.String n_GetValue ();
 
 
+	public static void staticMethodNotMangled ()
+	{
+		n_staticMethodNotMangled ();
+	}
+
+	private static native void n_staticMethodNotMangled ();
+
+
 	public void methodNamesNotMangled ()
 	{
 		n_methodNamesNotMangled ();
diff --git a/tests/Java.Interop.Tools.JavaCallableWrappers-Tests/Java.Interop.Tools.JavaCallableWrappers/SupportDeclarations.cs b/tests/Java.Interop.Tools.JavaCallableWrappers-Tests/Java.Interop.Tools.JavaCallableWrappers/SupportDeclarations.cs
index 4d8c228b..de99b77e 100644
--- a/tests/Java.Interop.Tools.JavaCallableWrappers-Tests/Java.Interop.Tools.JavaCallableWrappers/SupportDeclarations.cs
+++ b/tests/Java.Interop.Tools.JavaCallableWrappers-Tests/Java.Interop.Tools.JavaCallableWrappers/SupportDeclarations.cs
@@ -274,6 +274,11 @@ namespace Xamarin.Android.ToolsTests {
 			return "value";
 		}
 
+		[Export]
+		public static void staticMethodNotMangled ()
+		{
+		}
+
 		[Export]
 		public void methodNamesNotMangled ()
 		{

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note this is only excluding static methods that are on an interface that a class implements. It would not exclude a static method on a class. Should we allow [Export] on static interface methods?

Copy link
Contributor Author

@jpobst jpobst Nov 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this test case to PR even though it isn't directly affected by this, as it never hurts to have additional tests!

AddMethod (imethod, imethod);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ extends java.lang.Object
__md_methods =
""n_GetInstance:()Lcrc64197ae30a36756915/ExportsMembers;:__export__\n"" +
""n_GetValue:()Ljava/lang/String;:__export__\n"" +
""n_staticMethodNotMangled:()V:__export__\n"" +
""n_methodNamesNotMangled:()V:__export__\n"" +
""n_CompletelyDifferentName:(Ljava/lang/String;I)Ljava/lang/String;:__export__\n"" +
""n_methodThatThrows:()V:__export__\n"" +
Expand Down Expand Up @@ -218,6 +219,14 @@ public java.lang.String GetValue ()
private native java.lang.String n_GetValue ();


public static void staticMethodNotMangled ()
{
n_staticMethodNotMangled ();
}

private static native void n_staticMethodNotMangled ();


public void methodNamesNotMangled ()
{
n_methodNamesNotMangled ();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,11 @@ public string GetValue ()
return "value";
}

[Export]
public static void staticMethodNotMangled ()
{
}

[Export]
public void methodNamesNotMangled ()
{
Expand Down