<?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>InstanceOf - Revision history</title>
		<link>http://wiki.apidesign.org/index.php?title=InstanceOf&amp;action=history</link>
		<description>Revision history for this page on the wiki</description>
		<language>en</language>
		<generator>MediaWiki 1.12.0rc1</generator>
		<lastBuildDate>Sat, 11 Apr 2026 01:23:42 GMT</lastBuildDate>
		<item>
			<title>JaroslavTulach: New page: Properly used Covariance is said to be source compatible, but there is one language contruct which can lead to broken code - '''instanceof'''. The JavaC act...</title>
			<link>http://wiki.apidesign.org/index.php?title=InstanceOf&amp;diff=5219&amp;oldid=prev</link>
			<description>&lt;p&gt;New page: Properly used &lt;a href=&quot;/wiki/Covariance&quot; title=&quot;Covariance&quot;&gt;Covariance&lt;/a&gt; is said to be &lt;a href=&quot;/wiki/SourceCompatibility&quot; class=&quot;mw-redirect&quot; title=&quot;SourceCompatibility&quot;&gt;source compatible&lt;/a&gt;, but there is one language contruct which can lead to broken code - '''instanceof'''. The &lt;a href=&quot;/wiki/JavaC&quot; title=&quot;JavaC&quot;&gt;JavaC&lt;/a&gt; act...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Properly used [[Covariance]] is said to be [[SourceCompatibility|source compatible]], but there is one language contruct which can lead to broken code - '''instanceof'''. The [[JavaC]] acts cleverly and checks not just lower bound of the first parameter, but upper bound. For example following code is not going to compile:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
String s = &amp;quot;&amp;quot;;&lt;br /&gt;
assert s instanceof Integer;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The [[JavaC]] complains about ''inconvertible types''. Simple change to the program fixes the problem:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
Object s = &amp;quot;&amp;quot;;&lt;br /&gt;
assert s instanceof Integer;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Knowing this [[JavaC]] behavior, I am sure you can write code that will compile with the [[API]] used in [[Covariance]] example version 1.0 and will break the compilation against version 2.0. Am I right?&lt;/div&gt;</description>
			<pubDate>Wed, 19 Oct 2011 17:41:25 GMT</pubDate>			<dc:creator>JaroslavTulach</dc:creator>			<comments>http://wiki.apidesign.org/wiki/Talk:InstanceOf</comments>		</item>
	</channel>
</rss>