<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/css" href="http://wiki.apidesign.org/skins/common/feed.css?116"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
	<channel>
		<title>Covariance - Revision history</title>
		<link>http://wiki.apidesign.org/index.php?title=Covariance&amp;action=history</link>
		<description>Revision history for this page on the wiki</description>
		<language>en</language>
		<generator>MediaWiki 1.12.0rc1</generator>
		<lastBuildDate>Fri, 10 Apr 2026 23:18:27 GMT</lastBuildDate>
		<item>
			<title>JaroslavTulach at 15:32, 14 July 2016</title>
			<link>http://wiki.apidesign.org/index.php?title=Covariance&amp;diff=8903&amp;oldid=prev</link>
			<description>&lt;p&gt;&lt;/p&gt;

			&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;tr&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 15:32, 14 July 2016&lt;/td&gt;
			&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 22:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 22:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;As a result one cannot use [[Covariance]] or [[Contravariance]] in [[Java]] much. Unless one relies of on other side effects: There is a [[Erasure|larger example]] demonstrating that [[Covariance]] may work in [[Java]] undercertain circumstances.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;As a result one cannot use [[Covariance]] or [[Contravariance]] in [[Java]] much. Unless one relies of on other side effects: There is a [[Erasure|larger example]] demonstrating that [[Covariance]] may work in [[Java]] undercertain circumstances.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;[[Category:APIDesignPatterns]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;[[Category:APIDesignPatterns:Evolution]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</description>
			<pubDate>Thu, 14 Jul 2016 15:32:14 GMT</pubDate>			<dc:creator>JaroslavTulach</dc:creator>			<comments>http://wiki.apidesign.org/wiki/Talk:Covariance</comments>		</item>
		<item>
			<title>JaroslavTulach at 17:27, 19 October 2011</title>
			<link>http://wiki.apidesign.org/index.php?title=Covariance&amp;diff=5217&amp;oldid=prev</link>
			<description>&lt;p&gt;&lt;/p&gt;

			&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;tr&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 17:27, 19 October 2011&lt;/td&gt;
			&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Everything one would ever like to know about [[Covariance]] and [[Contravariance]] is available at [[wikipedia:Covariance_and_contravariance_(computer_science)|wikipedia]]. Here is just a small example how it does not work in [[Java]].&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Everything one would ever like to know about [[Covariance]] and [[Contravariance]] is available at [[wikipedia:Covariance_and_contravariance_(computer_science)|wikipedia]]. Here is just a small example &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;to show &lt;/ins&gt;how it does not work in [[Java]].&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Imagine simple program that computes maximum from two integers:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Imagine simple program that computes maximum from two integers:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 5:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 5:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;java&amp;quot; snippet=&amp;quot;variance.covariance.v1&amp;quot;/&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;java&amp;quot; snippet=&amp;quot;variance.covariance.v1&amp;quot;/&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;due to mistake the version 1.0 of the program does not return an {{JDK|java/lang|Integer}}, but rather its super type {{JDK|java/lang|Number}}. &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;Such return type &lt;/del&gt;can &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;still &lt;/del&gt;be &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;used to perform some &lt;/del&gt;useful &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;operations&lt;/del&gt;, but &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;it &lt;/del&gt;is cumbersome:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;due to &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;a &lt;/ins&gt;mistake the version 1.0 of the program does not return an {{JDK|java/lang|Integer}}, but rather its super type {{JDK|java/lang|Number}}. &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;This is not a complete mistake, even plain {{JDK|java/lang|Number}} &lt;/ins&gt;can be useful, but &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;its usage &lt;/ins&gt;is &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;a bit &lt;/ins&gt;cumbersome&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;. One needs to convert it to '''int''' first&lt;/ins&gt;:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;java&amp;quot; snippet=&amp;quot;variance.covariance.test&amp;quot;/&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;java&amp;quot; snippet=&amp;quot;variance.covariance.test&amp;quot;/&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;Thus in version 2.0 &lt;/del&gt;the author of the [[API]] &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;may decide &lt;/del&gt;to fix the &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;type to &lt;/del&gt;{{JDK|java/lang|Integer}}:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;Now imagine that &lt;/ins&gt;the author of the [[API]] &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;decides &lt;/ins&gt;to fix the &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;design flaw and release version 2.0 of the [[API]] where the method will return an &lt;/ins&gt;{{JDK|java/lang|Integer}}:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;java&amp;quot; snippet=&amp;quot;variance.covariance.v2&amp;quot;/&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;java&amp;quot; snippet=&amp;quot;variance.covariance.v2&amp;quot;/&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This is a &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;[[BackwardCompatible]] &lt;/del&gt;change from the &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;source &lt;/del&gt;point of view. Every (reasonable) code that compiled with version 1.0 will still compile (as {{JDK|java/lang|Integer}} contains all the method one could call on {{JDK|java/lang|Number}}). However this is heavily incompatible change from the point of &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;binary compatibility&lt;/del&gt;. Programs compiled against version 1.0 will not link against version 2.0 &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;as &lt;/del&gt;the [[JVM]] seeks method &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;that takes exactly &lt;/del&gt;one &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;'''&lt;/del&gt;Number&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;''' &lt;/del&gt;argument and &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;does not do any &lt;/del&gt;tricks with polymorphism &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;at all&lt;/del&gt;:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This is a &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;fine &lt;/ins&gt;change from the point of view &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;of [[SourceCompatibility]]&lt;/ins&gt;. Every (&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;[[InstanceOf|&lt;/ins&gt;reasonable&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;]]&lt;/ins&gt;) code that compiled with version 1.0 will still compile (as {{JDK|java/lang|Integer}} contains all the method one could call on {{JDK|java/lang|Number}}). However this is heavily incompatible change from the point of &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;[[BinaryCompatibility]]&lt;/ins&gt;. Programs compiled against version 1.0 will not link against version 2.0&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;. Unlike [[JavaC]], &lt;/ins&gt;the [[JVM]] seeks &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;for the proper &lt;/ins&gt;method &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;using an exact match. Only method with &lt;/ins&gt;one &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;{{JDK|java/lang|&lt;/ins&gt;Number&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;}} &lt;/ins&gt;argument &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;needs to be present &lt;/ins&gt;and &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;no &lt;/ins&gt;tricks with polymorphism &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;can help you cheat the [[JDK]]&lt;/ins&gt;:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 21:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 21:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;As a result one &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;can &lt;/del&gt;use [[Covariance]] or [[Contravariance]] in [[Java]] much. Unless one relies of [[Erasure]].&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;As a result one &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;cannot &lt;/ins&gt;use [[Covariance]] or [[Contravariance]] in [[Java]] much. Unless one relies of &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;on other side effects: There is a &lt;/ins&gt;[[Erasure&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;|larger example&lt;/ins&gt;]] &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;demonstrating that [[Covariance]] may work in [[Java]] undercertain circumstances&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</description>
			<pubDate>Wed, 19 Oct 2011 17:27:38 GMT</pubDate>			<dc:creator>JaroslavTulach</dc:creator>			<comments>http://wiki.apidesign.org/wiki/Talk:Covariance</comments>		</item>
		<item>
			<title>JaroslavTulach: New page: Everything one would ever like to know about Covariance and Contravariance is available at wikipedia. Here is just a ...</title>
			<link>http://wiki.apidesign.org/index.php?title=Covariance&amp;diff=5213&amp;oldid=prev</link>
			<description>&lt;p&gt;New page: Everything one would ever like to know about &lt;a href=&quot;/wiki/Covariance&quot; title=&quot;Covariance&quot;&gt;Covariance&lt;/a&gt; and &lt;a href=&quot;/wiki/Contravariance&quot; title=&quot;Contravariance&quot;&gt;Contravariance&lt;/a&gt; is available at &lt;a href=&quot;http://en.wikipedia.org/wiki/Covariance_and_contravariance_%28computer_science%29&quot; class=&quot;extiw&quot; title=&quot;wikipedia:Covariance_and_contravariance_(computer_science)&quot;&gt;wikipedia&lt;/a&gt;. Here is just a ...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Everything one would ever like to know about [[Covariance]] and [[Contravariance]] is available at [[wikipedia:Covariance_and_contravariance_(computer_science)|wikipedia]]. Here is just a small example how it does not work in [[Java]].&lt;br /&gt;
&lt;br /&gt;
Imagine simple program that computes maximum from two integers:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot; snippet=&amp;quot;variance.covariance.v1&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
due to mistake the version 1.0 of the program does not return an {{JDK|java/lang|Integer}}, but rather its super type {{JDK|java/lang|Number}}. Such return type can still be used to perform some useful operations, but it is cumbersome:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot; snippet=&amp;quot;variance.covariance.test&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus in version 2.0 the author of the [[API]] may decide to fix the type to {{JDK|java/lang|Integer}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot; snippet=&amp;quot;variance.covariance.v2&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a [[BackwardCompatible]] change from the source point of view. Every (reasonable) code that compiled with version 1.0 will still compile (as {{JDK|java/lang|Integer}} contains all the method one could call on {{JDK|java/lang|Number}}). However this is heavily incompatible change from the point of binary compatibility. Programs compiled against version 1.0 will not link against version 2.0 as the [[JVM]] seeks method that takes exactly one '''Number''' argument and does not do any tricks with polymorphism at all:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
Mixing does not work: Compiling against version 1.0 and running against version 2.0 of the API fails:&lt;br /&gt;
Exception in thread &amp;quot;main&amp;quot; java.lang.NoSuchMethodError: api.Covariance.max(II)Ljava/lang/Number;&lt;br /&gt;
	at test.CovarianceTest.main(Unknown Source)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As a result one can use [[Covariance]] or [[Contravariance]] in [[Java]] much. Unless one relies of [[Erasure]].&lt;/div&gt;</description>
			<pubDate>Tue, 18 Oct 2011 05:41:53 GMT</pubDate>			<dc:creator>JaroslavTulach</dc:creator>			<comments>http://wiki.apidesign.org/wiki/Talk:Covariance</comments>		</item>
	</channel>
</rss>