You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[generator] fix for NRE in FixupAccessModifiers (#299)
Context: 4ec5d4e
In improving our support for "package-private" classes, we added a
check to compare if two methods have the same signature. The
expression was of the form:
m.Name == baseMethod.Name && m.Parameters.JavaSignature == baseMethod.Parameters.JavaSignature
The problem with this is that the `JavaSignature` property can throw
a `NullReferenceException` if one of the parameter types is unknown,
or only becomes valid later on in generator's process:
System.NullReferenceException: Object reference not set to an instance of an object
at MonoDroid.Generation.Parameter.get_JavaType ()
at MonoDroid.Generation.ParameterList.get_JavaSignature ()
at MonoDroid.Generation.ClassGen+<>c__DisplayClass29_0.<FixupAccessModifiers>b__0 (MonoDroid.Generation.Method m)
at System.Linq.Enumerable.TryGetFirst[TSource] (System.Collections.Generic.IEnumerable`1[T] source, System.Func`2[T,TResult] predicate, System.Boolean& found)
at System.Linq.Enumerable.FirstOrDefault[TSource] (System.Collections.Generic.IEnumerable`1[T] source, System.Func`2[T,TResult] predicate)
at MonoDroid.Generation.ClassGen.FixupAccessModifiers ()
at Xamarin.Android.Binder.CodeGenerator.Validate (System.Collections.Generic.List`1[T] gens, MonoDroid.Generation.CodeGenerationOptions opt)
at Xamarin.Android.Binder.CodeGenerator.Run (Xamarin.Android.Binder.CodeGeneratorOptions options, Java.Interop.Tools.Cecil.DirectoryAssemblyResolver resolver)
at Xamarin.Android.Binder.CodeGenerator.Run (Xamarin.Android.Binder.CodeGeneratorOptions options)
at Xamarin.Android.Binder.CodeGenerator.Main (System.String[] args)
Instead of using `JavaSignature`, we need to rely *only* on the
original Java information, and loop over the parameters individually.
To fix this:
- Create a `bool Matches (MethodBase other)` method in `MethodBase`
- Override `Matches()` in `Method`, also check the return type
- Add some unit tests for these scenarios for both `XmlMethod` and
`ManagedMethod`
0 commit comments