mail-archives/monodroid/2012-November/012757.html

187 строки
9.4 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE> [mono-android] Binding classes don't implement Java.Lang.IComparable
</TITLE>
<LINK REL="Index" HREF="index.html" >
<LINK REL="made" HREF="mailto:monodroid%40lists.ximian.com?Subject=Re%3A%20%5Bmono-android%5D%20Binding%20classes%0A%09don%27t%09implement%09Java.Lang.IComparable&In-Reply-To=%3C509234E3.70409%40veritas-vos-liberabit.com%3E">
<META NAME="robots" CONTENT="index,nofollow">
<style type="text/css">
pre {
white-space: pre-wrap; /* css-2.1, curent FF, Opera, Safari */
}
</style>
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
<LINK REL="Next" HREF="012758.html">
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>[mono-android] Binding classes don't implement Java.Lang.IComparable</H1>
<B>Atsushi Eno</B>
<A HREF="mailto:monodroid%40lists.ximian.com?Subject=Re%3A%20%5Bmono-android%5D%20Binding%20classes%0A%09don%27t%09implement%09Java.Lang.IComparable&In-Reply-To=%3C509234E3.70409%40veritas-vos-liberabit.com%3E"
TITLE="[mono-android] Binding classes don't implement Java.Lang.IComparable">atsushieno at veritas-vos-liberabit.com
</A><BR>
<I>Thu Nov 1 08:37:55 UTC 2012</I>
<P><UL>
<LI>Next message: <A HREF="012758.html">[mono-android] 4.2.8: Provider fails to include authorities in AndroidManifest.xml
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#12757">[ date ]</a>
<a href="thread.html#12757">[ thread ]</a>
<a href="subject.html#12757">[ subject ]</a>
<a href="author.html#12757">[ author ]</a>
</LI>
</UL>
<HR>
<!--beginarticle-->
<PRE>Oh, OK. I discovered that things are much more complicated than it seemed.
First, you were right, Comparable&lt;T&gt; is (actually Comparable&lt;T&gt; and
Comarator&lt;T&gt; are) *special* case that *dropped* compareTo() method from
the API description XML. It is to be consistent with the existing AOSP's
API definition.
That have been special (at least, regarded so) and as a result it
becomes *mandatory* to get CompareTo() method.
And altering interface &lt;implements&gt; element by &lt;attr&gt; in Metadata.xml
doesn't work for this case, because unlike binding android.jar
java.lang.Comparable&lt;T&gt; cannot be looked up (it needs more investigation
to know precise situation, but as a general rule generics don't exist in
jar).
Hence, some Metadata.xml fixup has to be done manually, like:
&lt;add-node
path=&quot;/api/package[@name='com.lowagie.text']/class[@name='Font']&quot;&gt;
&lt;method name=&quot;compareTo&quot; return=&quot;int&quot; abstract=&quot;false&quot;
native=&quot;false&quot; synchronized=&quot;false&quot; static=&quot;false&quot; final=&quot;false&quot;
deprecated=&quot;not deprecated&quot; visibility=&quot;public&quot;&gt;
&lt;parameter name=&quot;o&quot; type=&quot;java.lang.Object&quot; /&gt;
&lt;/method&gt;
&lt;/add-node&gt;
It in general falls to &quot;generics only partially supported&quot; category of
binding limitations, but the recipe to deal with is slightly different,
which we weren't fully aware. So far please take this as a normative
way. Sorry for the missing information.
Apart from that, you will have to rename &quot;harmony.java.lang&quot; to
something different, because it brings conflict between &quot;Java.Lang&quot; and
&quot;Harmony.Java.Lang&quot; which has never been expected. This is hopefully
fixed in the next release but so far this is a limitation.
Thanks,
Atsushi Eno
Jeremy A. Kolb - ARA/NED wrote:
&gt;<i> No it definitely implements compateTo(java.lang.Object: &quot;public int compareTo(Object object)&quot;
</I>&gt;<i>
</I>&gt;<i> -----Original Message-----
</I>&gt;<i> From: <A HREF="http://lists.ximian.com/mailman/listinfo/monodroid">monodroid-bounces at lists.ximian.com</A> [mailto:<A HREF="http://lists.ximian.com/mailman/listinfo/monodroid">monodroid-bounces at lists.ximian.com</A>] On Behalf Of Atsushi Eno
</I>&gt;<i> Sent: Wednesday, October 31, 2012 3:40 PM
</I>&gt;<i> To: Discussions related to Mono for Android
</I>&gt;<i> Subject: Re: [mono-android] Binding classes don't implement Java.Lang.IComparable
</I>&gt;<i>
</I>&gt;<i> The implemented class doesn't contain compareTo(java.lang.Object) but compareTo(SomeSpecificType), whose type don't match and hence not regarded as implementation.
</I>&gt;<i>
</I>&gt;<i> If that's not about that, it is not likely about Comparable but different issue.
</I>&gt;<i>
</I>&gt;<i> Atsushi Eno
</I>&gt;<i>
</I>&gt;<i> Jeremy A. Kolb - ARA/NED wrote:
</I>&gt;&gt;<i> That doesn't make sense to me. IComparable.compareTo takes in an Object not another type so it shouldn't care about generics.
</I>&gt;&gt;<i>
</I>&gt;&gt;<i> -----Original Message-----
</I>&gt;&gt;<i> From: <A HREF="http://lists.ximian.com/mailman/listinfo/monodroid">monodroid-bounces at lists.ximian.com</A>
</I>&gt;&gt;<i> [mailto:<A HREF="http://lists.ximian.com/mailman/listinfo/monodroid">monodroid-bounces at lists.ximian.com</A>] On Behalf Of Atsushi Eno
</I>&gt;&gt;<i> Sent: Wednesday, October 31, 2012 3:25 PM
</I>&gt;&gt;<i> To: Discussions related to Mono for Android
</I>&gt;&gt;<i> Subject: Re: [mono-android] Binding classes don't implement
</I>&gt;&gt;<i> Java.Lang.IComparable
</I>&gt;&gt;<i>
</I>&gt;&gt;<i> Hello,
</I>&gt;&gt;<i>
</I>&gt;&gt;<i> That is a known limitation. The thing is, *generics don't really exist* in compiled java classes and we always need to explicitly supply which class the Comparable compares.
</I>&gt;&gt;<i>
</I>&gt;&gt;<i> Hence the solution is, you add appropriate instantiated generic interface to Metadata.xml. This is an example:
</I>&gt;&gt;<i>
</I>&gt;&gt;<i> &lt;attr
</I>&gt;&gt;<i> path=&quot;/api/package[@name='android.content']/class[@name='ComponentName']/implements[@name='java.lang.Comparable']&quot;
</I>&gt;&gt;<i> name=&quot;name&quot;&gt;java.lang.Comparable&lt;android.content.ComponentName&gt;&lt;
</I>&gt;&gt;<i> /attr&gt;
</I>&gt;&gt;<i>
</I>&gt;&gt;<i> Atsushi Eno
</I>&gt;&gt;<i>
</I>&gt;&gt;<i> Jeremy A. Kolb - ARA/NED wrote:
</I>&gt;&gt;&gt;<i> I'm trying to bind droidtext (<A HREF="http://code.google.com/p/droidtext">http://code.google.com/p/droidtext</A>) and
</I>&gt;&gt;&gt;<i> having a lot of trouble with classes not implementing
</I>&gt;&gt;&gt;<i> Java.Lang.IComparable.CompareTo. I can look at the java files and see
</I>&gt;&gt;&gt;<i> that the functions are implemented and public but bindings aren't
</I>&gt;&gt;&gt;<i> being generated for them. Has anyone seen this before? I don't see
</I>&gt;&gt;&gt;<i> anything in the logs about why this function isn't being picked up.
</I>&gt;&gt;&gt;<i>
</I>&gt;&gt;&gt;<i>
</I>&gt;&gt;&gt;<i>
</I>&gt;&gt;&gt;<i> _______________________________________________
</I>&gt;&gt;&gt;<i> Monodroid mailing list
</I>&gt;&gt;&gt;<i> <A HREF="http://lists.ximian.com/mailman/listinfo/monodroid">Monodroid at lists.ximian.com</A>
</I>&gt;&gt;&gt;<i>
</I>&gt;&gt;&gt;<i> UNSUBSCRIBE INFORMATION:
</I>&gt;&gt;&gt;<i> <A HREF="http://lists.ximian.com/mailman/listinfo/monodroid">http://lists.ximian.com/mailman/listinfo/monodroid</A>
</I>&gt;&gt;<i> _______________________________________________
</I>&gt;&gt;<i> Monodroid mailing list
</I>&gt;&gt;<i> <A HREF="http://lists.ximian.com/mailman/listinfo/monodroid">Monodroid at lists.ximian.com</A>
</I>&gt;&gt;<i>
</I>&gt;&gt;<i> UNSUBSCRIBE INFORMATION:
</I>&gt;&gt;<i> <A HREF="http://lists.ximian.com/mailman/listinfo/monodroid">http://lists.ximian.com/mailman/listinfo/monodroid</A>
</I>&gt;&gt;<i> _______________________________________________
</I>&gt;&gt;<i> Monodroid mailing list
</I>&gt;&gt;<i> <A HREF="http://lists.ximian.com/mailman/listinfo/monodroid">Monodroid at lists.ximian.com</A>
</I>&gt;&gt;<i>
</I>&gt;&gt;<i> UNSUBSCRIBE INFORMATION:
</I>&gt;&gt;<i> <A HREF="http://lists.ximian.com/mailman/listinfo/monodroid">http://lists.ximian.com/mailman/listinfo/monodroid</A>
</I>&gt;&gt;<i>
</I>&gt;&gt;<i>
</I>&gt;&gt;<i>
</I>&gt;<i> _______________________________________________
</I>&gt;<i> Monodroid mailing list
</I>&gt;<i> <A HREF="http://lists.ximian.com/mailman/listinfo/monodroid">Monodroid at lists.ximian.com</A>
</I>&gt;<i>
</I>&gt;<i> UNSUBSCRIBE INFORMATION:
</I>&gt;<i> <A HREF="http://lists.ximian.com/mailman/listinfo/monodroid">http://lists.ximian.com/mailman/listinfo/monodroid</A>
</I>&gt;<i> _______________________________________________
</I>&gt;<i> Monodroid mailing list
</I>&gt;<i> <A HREF="http://lists.ximian.com/mailman/listinfo/monodroid">Monodroid at lists.ximian.com</A>
</I>&gt;<i>
</I>&gt;<i> UNSUBSCRIBE INFORMATION:
</I>&gt;<i> <A HREF="http://lists.ximian.com/mailman/listinfo/monodroid">http://lists.ximian.com/mailman/listinfo/monodroid</A>
</I>&gt;<i>
</I>&gt;<i>
</I>&gt;<i>
</I>
</PRE>
<!--endarticle-->
<HR>
<P><UL>
<!--threads-->
<LI>Next message: <A HREF="012758.html">[mono-android] 4.2.8: Provider fails to include authorities in AndroidManifest.xml
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#12757">[ date ]</a>
<a href="thread.html#12757">[ thread ]</a>
<a href="subject.html#12757">[ subject ]</a>
<a href="author.html#12757">[ author ]</a>
</LI>
</UL>
<hr>
<a href="http://lists.ximian.com/mailman/listinfo/monodroid">More information about the Monodroid
mailing list</a><br>
</body></html>