Bug 23879 - Java.Util.IIterator / change type
Summary: Java.Util.IIterator / change type
Status: RESOLVED ANSWERED
Alias: None
Product: Android
Classification: Xamarin
Component: Bindings ()
Version: 0.0 (Samples)
Hardware: All Mac OS
: Normal normal
Target Milestone: ---
Assignee: Atsushi Eno
URL:
Depends on:
Blocks:
 
Reported: 2014-10-16 13:53 UTC by manuel
Modified: 2016-08-08 07:54 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Metadata configuration (8.47 KB, text/xml)
2014-10-16 13:53 UTC, manuel
Details
metadata configuration (8.47 KB, application/xml)
2014-10-16 13:59 UTC, manuel
Details
Current Version of binding (706.15 KB, application/zip)
2014-10-17 07:35 UTC, manuel
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description manuel 2014-10-16 13:53:29 UTC
Created attachment 8433 [details]
Metadata configuration

We are trying to bind mp4Parser (https://github.com/sannies/mp4parser) and had a blocker in the following class

Com.Googlecode.Mp4parser.BasicContainer, that implements Java.Util.IIterator

First error that we got is ok.

Error 1 - MP4Parser/obj/Debug/generated/src/Com.Googlecode.Mp4parser.BasicContainer.cs(23,23): Error CS0738: `Com.Googlecode.Mp4parser.BasicContainer' does not implement interface member `Java.Util.IIterator.Next()' and the best implementing candidate `Com.Googlecode.Mp4parser.BasicContainer.Next()' return type `Com.Coremedia.Iso.Boxes.IBox' does not match interface member return type `Java.Lang.Object' (CS0738) (MP4Parser)

To solve it we did the following in Metadata.xml:

<attr path="/api/package[@name='/api/package[@name='com.googlecode.mp4parser']/class[@name='BasicContainer']/method[@name='next' and count(parameter)=0]" name="managedReturn">Java.Lang.Object</attr>

This creates two errors with the same message and does not generate source code

Error 2 - /MP4Parser/MonoDroid.Generation.BindingGeneratorException: Error BG4304: Invalid XPath specification: /api/package[@name='/api/package[@name='com.googlecode.mp4parser']/class[@name='BasicContainer']/method[@name='next' and count(parameter)=0] (BG4304) (MP4Parser)

If we remove the following line from metadata.xml we'll go back to Error 1.

<attr path="/api/package[@name='/api/package[@name='com.googlecode.mp4parser']/class[@name='BasicContainer']/method[@name='next' and count(parameter)=0]" name="managedReturn">Java.Lang.Object</attr>

Interesting part is this. Code created automatically is this

/ Metadata.xml XPath method reference: path="/api/package[@name='com.googlecode.mp4parser']/class[@name='BasicContainer']/method[@name='next' and count(parameter)=0]"
[Register ("next", "()Lcom/coremedia/iso/boxes/Box;", "GetNextHandler")]
public virtual global::Com.Coremedia.Iso.Boxes.IBox Next ()
{
     if (id_next == IntPtr.Zero)
     id_next = JNIEnv.GetMethodID (class_ref, "next", "()Lcom/coremedia/iso/boxes/Box;");

     if (GetType () == ThresholdType)
          return global::Java.Lang.Object.GetObject<global::Com.Coremedia.Iso.Boxes.IBox> (JNIEnv.CallObjectMethod  (Handle, id_next), JniHandleOwnership.TransferLocalRef);
     else
          return global::Java.Lang.Object.GetObject<global::Com.Coremedia.Iso.Boxes.IBox> (JNIEnv.CallNonvirtualObjectMethod  (Handle, ThresholdClass, JNIEnv.GetMethodID (ThresholdClass, "next", "()Lcom/coremedia/iso/boxes/Box;")), JniHandleOwnership.TransferLocalRef);
}

Having said that, it seems that if we change the returned type, return methods will have no cast to Java.Lang.Object producing some internal error. 

cheers
Comment 1 manuel 2014-10-16 13:59:10 UTC
Created attachment 8434 [details]
metadata configuration
Comment 2 manuel 2014-10-16 14:06:33 UTC
Not sure if attachments were working. Here you can find Metadata.xml

<metadata>
<!--        <remove-node path="/api/package[@name='com.coremedia.iso']" />
 		<remove-node path="/api/package[@name='com.coremedia.iso.boxes']" />
		<remove-node path="/api/package[@name='com.coremedia.iso.boxes.apple']" />
		<remove-node path="/api/package[@name='com.coremedia.iso.boxes.dece']" />
		<remove-node path="/api/package[@name='com.coremedia.iso.boxes.fragment']" />
		<remove-node path="/api/package[@name='com.coremedia.iso.boxes.mdat']" />
		<remove-node path="/api/package[@name='com.coremedia.iso.boxes.sampleentry']" />
		<remove-node path="/api/package[@name='com.coremedia.iso.boxes.threegpp26244']" />
		<remove-node path="/api/package[@name='com.coremedia.iso.boxes.vodafone']" />-->

<!--		<remove-node path="/api/package[@name='com.googlecode.mp4parser']" />-->
		<remove-node path="/api/package[@name='com.googlecode.mp4parser.annotations']" />
		<remove-node path="/api/package[@name='com.googlecode.mp4parser.authoring']" />
		<remove-node path="/api/package[@name='com.googlecode.mp4parser.authoring.builder']" />
		<remove-node path="/api/package[@name='com.googlecode.mp4parser.authoring.container.mp4']" />
		<remove-node path="/api/package[@name='com.googlecode.mp4parser.authoring.samples']" />
		<remove-node path="/api/package[@name='com.googlecode.mp4parser.authoring.tracks']" />
		<remove-node path="/api/package[@name='com.googlecode.mp4parser.boxes']" />
		<remove-node path="/api/package[@name='com.googlecode.mp4parser.boxes.adobe']" />
		<remove-node path="/api/package[@name='com.googlecode.mp4parser.boxes.apple']" />
		<remove-node path="/api/package[@name='com.googlecode.mp4parser.boxes.basemediaformat']" />
		<remove-node path="/api/package[@name='com.googlecode.mp4parser.boxes.cenc']" />
		<remove-node path="/api/package[@name='com.googlecode.mp4parser.boxes.dece']" />
		<remove-node path="/api/package[@name='com.googlecode.mp4parser.boxes.mp4']" />
		<remove-node path="/api/package[@name='com.googlecode.mp4parser.boxes.mp4.objectdescriptors']" />
		<remove-node path="/api/package[@name='com.googlecode.mp4parser.boxes.mp4.samplegrouping']" />
		<remove-node path="/api/package[@name='com.googlecode.mp4parser.boxes.piff']" />
		<remove-node path="/api/package[@name='com.googlecode.mp4parser.boxes.threegpp26244']" />
		<remove-node path="/api/package[@name='com.googlecode.mp4parser.boxes.threegpp26245']" />

		<remove-node path="/api/package[@name='com.googlecode.mp4parser.contentprotection']" />
		<remove-node path="/api/package[@name='com.googlecode.mp4parser.h264']" />
		<remove-node path="/api/package[@name='com.googlecode.mp4parser.h264.model']" />
		<remove-node path="/api/package[@name='com.googlecode.mp4parser.h264.read']" />
		<remove-node path="/api/package[@name='com.googlecode.mp4parser.h264.write']" />
		<remove-node path="/api/package[@name='com.googlecode.mp4parser.srt']" />
		<remove-node path="/api/package[@name='com.googlecode.mp4parser.util']" />

		<remove-node path="/api/package[@name='com.mp4parser.iso14496.part12']" />
		<remove-node path="/api/package[@name='com.mp4parser.iso14496.part15']" />
		<remove-node path="/api/package[@name='com.mp4parser.iso23001.part7']" />
		<remove-node path="/api/package[@name='com.mp4parser.iso23009.part1']" />


		<attr path="/api/package[@name='com.coremedia.iso.boxes.mdat']/class[@name='SampleList']" name="abstract">true</attr>

<!--		<attr path="/api/package[@name='/api/package[@name='com.googlecode.mp4parser']/class[@name='BasicContainer']/method[@name='next' and count(parameter)=0]" name="managedReturn">Java.Lang.Object</attr>-->








<!--
	<attr path="/api/package[@name='com.googlecode.mp4parser']/class[@name='BasicContainer']/method[@name='next' and count(parameter)=0]" name="managedReturn">Com.Coremedia.Iso.Boxes.IBox</attr>-->



        <attr path="/api/package[@name='com.googlecode.mp4parser.h264']/class[@name='Debug']/field[@name='debug']" name="managedName">_Debug</attr>
        <attr path="/api/package[@name='com.googlecode.mp4parser.h264.model']/class[@name='ScalingList']/field[@name='scalingList']" name="managedName">_ScalingList</attr>
        <attr path="/api/package[@name='com.googlecode.mp4parser']/class[@name='Version']/field[@name='VERSION']" name="managedName">_Version</attr>
<!--
        <attr path="/api/package[@name='com.coremedia.iso.boxes.mdat']/class[@name='SampleList']/method[@name='get']" name="managedReturn">Java.Lang.Object</attr>
        <attr path="/api/package[@name='com.coremedia.iso.boxes.mdat']/class[@name='SampleList']/method[@name='get']" name="override">true</attr>
        <attr path="/api/package[@name='com.coremedia.iso.boxes.mdat']/class[@name='SampleList']/method[@name='get']" name="virtual">false</attr>

        <attr path="/api/package[@name='com.googlecode.mp4parser.authoring.samples']/class[@name='FragmentedMp4SampleList']/method[@name='get']" name="managedReturn">Java.Lang.Object</attr>
        <attr path="/api/package[@name='com.googlecode.mp4parser.authoring.samples']/class[@name='FragmentedMp4SampleList']/method[@name='get']" name="override">true</attr>
        <attr path="/api/package[@name='com.googlecode.mp4parser.authoring.samples']/class[@name='FragmentedMp4SampleList']/method[@name='get']" name="virtual">false</attr>

        <attr path="/api/package[@name='com.googlecode.mp4parser.authoring.tracks']/class[@name='DecryptedSampleList']/method[@name='get']" name="managedReturn">Java.Lang.Object</attr>
        <attr path="/api/package[@name='com.googlecode.mp4parser.authoring.tracks']/class[@name='DecryptedSampleList']/method[@name='get']" name="override">true</attr>
        <attr path="/api/package[@name='com.googlecode.mp4parser.authoring.tracks']/class[@name='DecryptedSampleList']/method[@name='get']" name="virtual">false</attr>

        <attr path="/api/package[@name='com.googlecode.mp4parser.authoring.samples']/class[@name='DefaultMp4SampleList']/method[@name='get']" name="managedReturn">Java.Lang.Object</attr>
        <attr path="/api/package[@name='com.googlecode.mp4parser.authoring.samples']/class[@name='DefaultMp4SampleList']/method[@name='get']" name="override">true</attr>
        <attr path="/api/package[@name='com.googlecode.mp4parser.authoring.samples']/class[@name='DefaultMp4SampleList']/method[@name='get']" name="virtual">false</attr>

        <attr path="/api/package[@name='com.googlecode.mp4parser.boxes.cenc']/class[@name='CencDecryptingSampleList']/method[@name='get']" name="managedReturn">Java.Lang.Object</attr>
        <attr path="/api/package[@name='com.googlecode.mp4parser.boxes.cenc']/class[@name='CencDecryptingSampleList']/method[@name='get']" name="override">true</attr>
        <attr path="/api/package[@name='com.googlecode.mp4parser.boxes.cenc']/class[@name='CencDecryptingSampleList']/method[@name='get']" name="virtual">false</attr>

        <attr path="/api/package[@name='com.googlecode.mp4parser.boxes.cenc']/class[@name='CencEncryptingSampleList']/method[@name='get']" name="managedReturn">Java.Lang.Object</attr>
        <attr path="/api/package[@name='com.googlecode.mp4parser.boxes.cenc']/class[@name='CencEncryptingSampleList']/method[@name='get']" name="override">true</attr>
        <attr path="/api/package[@name='com.googlecode.mp4parser.boxes.cenc']/class[@name='CencEncryptingSampleList']/method[@name='get']" name="virtual">false</attr>

        <attr path="/api/package[@name='com.googlecode.mp4parser.authoring.tracks']/class[@name='ReplaceSampleTrack']/method[@name='get']" name="managedReturn">Java.Lang.Object</attr>
        <attr path="/api/package[@name='com.googlecode.mp4parser.authoring.tracks']/class[@name='ReplaceSampleTrack']/method[@name='get']" name="override">true</attr>
        <attr path="/api/package[@name='com.googlecode.mp4parser.authoring.tracks']/class[@name='ReplaceSampleTrack']/method[@name='get']" name="virtual">false</attr>

        <attr path="/api/package[@name='com.googlecode.mp4parser.authoring.tracks']/class[@name='ReplaceSampleTrack.ReplaceASingleEntryList']/method[@name='get']" name="managedReturn">Java.Lang.Object</attr>
        <attr path="/api/package[@name='com.googlecode.mp4parser.authoring.tracks']/class[@name='ReplaceSampleTrack.ReplaceASingleEntryList']/method[@name='get']" name="override">true</attr>
        <attr path="/api/package[@name='com.googlecode.mp4parser.authoring.tracks']/class[@name='ReplaceSampleTrack.ReplaceASingleEntryList']/method[@name='get']" name="virtual">false</attr>-->

<!--        <attr path="/api/package[@name='com.googlecode.mp4parser']/interface[@name='DataSource']/method[@name='close' and count(parameter)=0]" name="new">true</attr>-->
         



</metadata>
Comment 3 Atsushi Eno 2014-10-16 18:40:08 UTC
Error 2 - /MP4Parser/MonoDroid.Generation.BindingGeneratorException: Error
BG4304: Invalid XPath specification:
/api/package[@name='/api/package[@name='com.googlecode.mp4parser']/class[@name='BasicContainer']/method[@name='next'
and count(parameter)=0] (BG4304) (MP4Parser)

This is correct error message. You indeed specified invalid XPath. Please fix your code and try further.
Comment 4 manuel 2014-10-17 07:33:36 UTC
Atsushi,

thanks, what a stupid bug! 
After that we were did move a few steps forward. We managed to get into a situation where we were able to compile with the following packages out.
  
<remove-node path="/api/package[@name='com.googlecode.mp4parser.authoring']" /> 
<remove-node path="/api/package[@name='com.googlecode.mp4parser.authoring.tracks']" />

When we tried to add "com.googlecode.mp4parser.authoring", 4 errors appeared complaining with missing classes:

MP4Parser/obj/Debug/generated/src/Com.Googlecode.Mp4parser.Authoring.AbstractTrack.cs(85,85): Error CS0234: The type or namespace name `CompositionTimeToSample' does not exist in the namespace `Com.Coremedia.Iso.Boxes'. Are you missing an assembly reference? (CS0234) (MP4Parser) 

MP4Parser/obj/Debug/generated/src/Com.Googlecode.Mp4parser.Authoring.AbstractTrack.cs(85,85): Error CS0234: The type or namespace name `SampleDependencyTypeBox' does not exist in the namespace `Com.Coremedia.Iso.Boxes'. Are you missing an assembly reference? (CS0234) (MP4Parser)

At this stage we looked to warnings and just realised a lot of classes were missing, including these two ones.

MP4Parser/JARTOXML: Warning J2XA006: missing class error was raised while reflecting com.coremedia.iso.boxes.CompositionTimeToSample : org/aspectj/lang/Signature (J2XA006) (MP4Parser)

/Users/nativolabs/Documents/Code/Storyo/Shared/MP4Parser/JARTOXML: Warning J2XA006: missing class error was raised while reflecting com.coremedia.iso.boxes.SampleDependencyTypeBox : org/aspectj/lang/Signature (J2XA006) (MP4Parser)

Any suggestion how to move on? In fact this is one of the key packages that we require. We'll attach current version of the project.
Comment 5 manuel 2014-10-17 07:35:03 UTC
Created attachment 8441 [details]
Current Version of binding
Comment 6 manuel 2014-10-17 12:20:31 UTC
I think that the issues that we are having are mainly caused by circular references in this library.
Comment 7 Atsushi Eno 2014-10-28 09:01:38 UTC
As long as your library exposes aspectj API in the public API, you have to add aspectj jar as EmbeddedJar also bind them.
Comment 8 Atsushi Eno 2016-08-08 07:54:37 UTC
Not sure why this bug was left open, there seems to be no "bug" here anymore.