[Xamarin.Android.Tools.Bytecode] Support @JvmOverloads #651
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
@moljac ran into an interesting warning from
class-parse
whenbinding OfficeUIFrabric:
For starters, this shouldn't be a warning; it's not actionable.
There is nothing a user can do to fix this warning; it's only
meaningful to the Java.Interop team.
Update
Xamarin.Android.Tools.Bytecode.MethodInfo.GetParameters()
sothat these messages are debug messages, not warnings.
class-parse
knows how many parameters are present based on the JNImethod descriptor, in this case
(Landroid/content/Context;)V
, whichspecifies one parameter type. The JNI descriptor doesn't contain
parameter name information; where do parameter names come from?
If the
.class
file was built viajavac -parameters
, then theMethodParametersAttribute
blob can be used; see 4273e5c.However, before checking for
MethodParametersAttribute
,class-parse
will attempt to use theLocalVariableTableAttribute
and
LocalVariableTableEntry
values to infer parameter names.As part of this inference, method parameters are assumed to be
variables with
LocalVariableTableEntry.StartPC
is 0; fromclass-parse --dump BottomNavigationView.class
:Next,
class-parse
will "skip" the first variable for instancemethods. This results in "skipping" the
context
variable, resultingin the message:
To fix this,
class-parse
needs a stricter "skip thethis
parameter" check: the first parameter should only be skipped when:
static
method, anddescriptor of the declaring type.
Additionally, update the code style to use
enumValue.HasFlag(V)
instead of
(enumValue & V) == V
for readability.Finally, why was this failing in the first place? In some
circumstances, when the Kotlin [
@JvmOverloads
][2] annotation is usedon a
constructor
, Kotlin will emit all possible overloads for theconstructor, and in many of those overloads the
this
parameterwon't be present in the
LocalVariableTableAttribute
data, as seenabove with
BottomNavigationView
.