Skip to content

[Xamarin.Android.Tools.Bytecode] Allow null enclosing method #479

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Aug 18, 2019

Conversation

jonpryor
Copy link
Contributor

Context: dotnet/android#3504
Context: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=2951424&view=ms.vss-test-web.build-test-results-tab&runId=7990780&resultId=100107&paneView=attachments

The attempt to bump the Java.Interop submodule within xamarin-android
hit a snag, as unit tests failed:

The "ClassParse" task failed unexpectedly.
System.NullReferenceException: Object reference not set to an instance of an object
  at Xamarin.Android.Tools.Bytecode.ClassFile.TryGetEnclosingMethodInfo (System.String& declaringClass, System.String& declaringMethod, System.String& declaringDescriptor)
  at Xamarin.Android.Tools.Bytecode.XmlClassDeclarationBuilder.GetEnclosingMethod ()
  at Xamarin.Android.Tools.Bytecode.XmlClassDeclarationBuilder.ToXElement ()
  at Xamarin.Android.Tools.Bytecode.ClassPath+<>c.<ToXElement>b__36_3 (Xamarin.Android.Tools.Bytecode.ClassFile c)
  at System.Linq.Enumerable+SelectIPartitionIterator`2[TSource,TResult].MoveNext ()
  at System.Xml.Linq.XContainer.AddContentSkipNotify (System.Object content)
  at System.Xml.Linq.XContainer.AddContentSkipNotify (System.Object content)

The cause? The material-menu library has .class files which
have an EnclosingMethod attribute blob, but doesn't mention method
name information, only an enclosing type:

$ mono class-parse.exe com/balysv/material/drawable/menu/MaterialMenuDrawable\$5.class --dump
...
    1: EnclosingMethod(Class(nameIndex=58 Name="com/balysv/material/drawable/menu/MaterialMenuDrawable"), )
# Behold! No method information!

Support generating an XML description of this type by adding
appropriate null checks around EnclosingMethodAttribute.

Context: dotnet/android#3504
Context: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=2951424&view=ms.vss-test-web.build-test-results-tab&runId=7990780&resultId=100107&paneView=attachments

The attempt to bump the Java.Interop submodule within xamarin-android
hit a snag, as unit tests failed:

	The "ClassParse" task failed unexpectedly.
	System.NullReferenceException: Object reference not set to an instance of an object
	  at Xamarin.Android.Tools.Bytecode.ClassFile.TryGetEnclosingMethodInfo (System.String& declaringClass, System.String& declaringMethod, System.String& declaringDescriptor)
	  at Xamarin.Android.Tools.Bytecode.XmlClassDeclarationBuilder.GetEnclosingMethod ()
	  at Xamarin.Android.Tools.Bytecode.XmlClassDeclarationBuilder.ToXElement ()
	  at Xamarin.Android.Tools.Bytecode.ClassPath+<>c.<ToXElement>b__36_3 (Xamarin.Android.Tools.Bytecode.ClassFile c)
	  at System.Linq.Enumerable+SelectIPartitionIterator`2[TSource,TResult].MoveNext ()
	  at System.Xml.Linq.XContainer.AddContentSkipNotify (System.Object content)
	  at System.Xml.Linq.XContainer.AddContentSkipNotify (System.Object content)

The cause?  The [`material-menu`][0] library has `.class` files which
have an `EnclosingMethod` attribute blob, but doesn't mention method
name information, only an enclosing type:

	$ mono class-parse.exe com/balysv/material/drawable/menu/MaterialMenuDrawable\$5.class --dump
	...
	    1: EnclosingMethod(Class(nameIndex=58 Name="com/balysv/material/drawable/menu/MaterialMenuDrawable"), )
	# Behold! No method information!

Support generating an XML description of this type by adding
appropriate `null` checks around `EnclosingMethodAttribute`.

[0]: https://repo.jfrog.org/artifactory/libs-release-bintray/com/balysv/material-menu/1.1.0/material-menu-1.1.0.aar
@jonpryor jonpryor merged commit 7228af0 into dotnet:master Aug 18, 2019
@jonpryor jonpryor deleted the jonp-relax-enclosing-method-info branch August 18, 2019 01:37
@github-actions github-actions bot locked and limited conversation to collaborators Apr 13, 2024
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant