Skip to content

Commit

Permalink
[Java.Interop] Fix JNI signature generating
Browse files Browse the repository at this point in the history
Commit
dotnet@cb161d2
introduced a regression described in
dotnet/android#1149 (comment)

The signature of the `InitializeCreator` method was wrongly calculated
as `()Ljava/lang/Object;` instead of original
`()Lmd59b7a7576784821ea63294fbca8600da1/Creator_1;`

The reason for that is, that
dotnet@cb161d2#diff-9e153905b02dbe50c0e0b874ba40bf3eR262
started using `IEnumerable<T>::OfType<T>`, which traverses
inheritance, unlike the original `Type::GetCustomAttributes` called
with `inherit = false`.

Thus for the `Creator<Player>` we got the `RegisterAttribute` from the
parent type `Java.Lang.Object` which led to non-null result from
`ToJniNameFromAttributes` method. At the end the result was used here
dotnet@cb161d2#diff-9e153905b02dbe50c0e0b874ba40bf3eR361
instead of returning `ToJniName (type, exportKind)` result.
  • Loading branch information
radekdoulik committed Jan 8, 2018
1 parent ff8218a commit 8af87ff
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,8 @@ static string GetSpecialExportJniType (string typeName, ExportParameterKind expo
// Keep in sync with ToJniNameFromAttributes(TypeDefinition)
public static string ToJniNameFromAttributes (Type type)
{
var a = type.GetCustomAttributes ().OfType<IJniNameProviderAttribute> ().FirstOrDefault (j => !string.IsNullOrEmpty (j.Name));
return a == null ? null : a.Name.Replace ('.', '/');
var aa = (IJniNameProviderAttribute []) type.GetCustomAttributes (typeof (IJniNameProviderAttribute), false);
return aa.Length > 0 && !string.IsNullOrEmpty (aa [0].Name) ? aa [0].Name.Replace ('.', '/') : null;
}

/*
Expand Down

0 comments on commit 8af87ff

Please sign in to comment.