Bug 6039 - jar2xml needs to declare @Override methods which also come from interfaces
Summary: jar2xml needs to declare @Override methods which also come from interfaces
Alias: None
Product: Android
Classification: Xamarin
Component: Bindings ()
Version: 4.2.x
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Atsushi Eno
Depends on:
Reported: 2012-07-08 15:11 UTC by Craig
Modified: 2013-06-21 07:58 UTC (History)
3 users (show)

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

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:

Description Craig 2012-07-08 15:11:03 UTC
I'm trying to bind this class (follow link below): 

<a href="http://codeviewer.org/view/code:27cb">Click here for code</a>

The important thing to note is that the class contains a method called setEnabled. 

However when I build the JAR binding project this method is not included in the api.xml that is generated and it is causing an error in the generated C# code since this method is missing. 

Here is the portion from the api.xml related to this class:

<a href="http://codeviewer.org/view/code:27d7">Click here for XML</a>

As far as I can tell this problem is occuring because the android.view.View class contains a method called setEnabled and the com.actionbarsherlock.internal.view.menu.MenuView.ItemView interface also contains a method called setEnabled.  I'm not able to confirm this but I have a gut feeling that this is the problem.  Still looking for a way to work-around / resolve this.
Comment 1 Craig 2012-07-08 15:16:21 UTC
Oh the Java project I'm trying to bind is Actionbar Sherlock.  You can download the same JAR file that I'm working with here: http://www.sendspace.com/file/xncigz (when you click the link its the download link in the small, blue box towards the bottom, all the other junk is a bunch of ads)
Comment 2 Jonathan Pryor 2012-07-09 11:37:23 UTC
> http://codeviewer.org/view/code:27cb

Silly question, but why do you want to bind an internal class? It's in the package: com.actionbarsherlock.internal.view.menu, which implies that it's for internal use. Furthermore, the type has a @hide doc-comment, which prevents it from being exposed in JavaDoc.

> The important thing to note is that the class contains a method called setEnabled

setEnabled() isn't present within the API description because it's an @Override method, and method overrides (normally) aren't bound, as they don't need to be bound.

Is there a build error or runtime error that you're seeing?

 - Jon
Comment 3 Craig 2012-07-09 12:01:56 UTC
Thanks, I guess I hadn't even thought about it that way.  You are probably right, I doubt I need to bind the internal classes, which makes my job a lot easier.  So that actually eliminates this problem for me.  Thanks.

However, I think there still might be a bug, IF I were to try to bind these classes.

The error message I'm seeing is this:

Error	2	'Com.Actionbarsherlock.Internal.View.Menu.ListMenuItemView' does not implement interface member 'Com.Actionbarsherlock.Internal.View.Menu.IMenuViewItemView.SetEnabled(bool)'	C:\Users\CSchulte\Documents\Visual Studio 2010\Projects\AndroidApplication4\BindingLibrary1\obj\Debug\generated\src\Com.Actionbarsherlock.Internal.View.Menu.ListMenuItemView.cs	8	23	BindingLibrary1

So I guess I originally thought this error message was caused by the method not being present in the api.xml file, but as you have explained that is not necessarily the case.  But, regardless, the method is not present in my generated JAR Binding code either, so it causes the error message since it is not implemented like it should be.
Comment 4 Craig 2012-07-09 12:04:06 UTC
Please see previous comment.  I'm not positive it is really a bug but it seems like it might be.  Thanks.
Comment 5 Jonathan Pryor 2012-07-09 12:10:43 UTC
You are correct: the issue is that setEnabled() is declared in the MenuViewItemView interface, but it isn't declared in ListMenuItemView because setEnabled() is _also_ a method override.

This is a bug: either jar2xml needs to declare the method in the XML description, or generator needs to check implemented interfaces and generate the methods.
Comment 6 Atsushi Eno 2013-06-21 07:58:52 UTC
To be consistent with the original AOSP format, jar2xml should NOT generate overriden methods that is covered in the base interfaces.
If things are missing then generator should handle it, unless it should NOT do - for example, return type has changed and it should be left for user which (of base type or derived type) to bind.

Since we made several changes in the binding generator and this sample code is too old (I cannot even see the pastes as they are expired) but we have a working ActionBarSherlock binding in our monodroid-samples repository (which I believe works quite well, as long as I could run the port of its sample), I just close this as fixed. If you still have problem please reopen or create another bug if that is different state than this.