<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: When protected isn&#8217;t protected</title>
	<atom:link href="http://dow.ngra.de/2008/11/03/when-protected-isnt-protected/feed/" rel="self" type="application/rss+xml" />
	<link>http://dow.ngra.de/2008/11/03/when-protected-isnt-protected/</link>
	<description>no buzzwords allowed</description>
	<lastBuildDate>Wed, 01 Feb 2012 18:42:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Jevgeni Kabanov</title>
		<link>http://dow.ngra.de/2008/11/03/when-protected-isnt-protected/comment-page-1/#comment-3109</link>
		<dc:creator>Jevgeni Kabanov</dc:creator>
		<pubDate>Tue, 04 Nov 2008 16:08:49 +0000</pubDate>
		<guid isPermaLink="false">http://dow.ngra.de/?p=360#comment-3109</guid>
		<description>@Jing

Yes, I just brought it as an easier to understand example. JVM must also enforce the Java access rules, one of them is that &quot;protected&quot; members can only be accessed by either members of the same package or subclasses. Verifier cannot check the subclass restriction fully, therefore INVOKEVIRTUAL does an extra check (quoted):

&lt;blockquote&gt;Finally, if the resolved method is protected (§4.6), and it is either a member of the current class or a member of a superclass of the current class, then the class of objectref must be either the current class or a subclass of the current class.&lt;/blockquote&gt;

&lt;code&gt;String[]&lt;/code&gt; is obviously *not* a subclass of &lt;code&gt;XMLEntityManager&lt;/code&gt; therefore this call should not be allowed. If you check the bug reports I&#039;m referring, it is clear that the JVM engineers are aware that this is a bug.</description>
		<content:encoded><![CDATA[<p>@Jing</p>
<p>Yes, I just brought it as an easier to understand example. JVM must also enforce the Java access rules, one of them is that &#8220;protected&#8221; members can only be accessed by either members of the same package or subclasses. Verifier cannot check the subclass restriction fully, therefore INVOKEVIRTUAL does an extra check (quoted):</p>
<blockquote><p>Finally, if the resolved method is protected (§4.6), and it is either a member of the current class or a member of a superclass of the current class, then the class of objectref must be either the current class or a subclass of the current class.</p></blockquote>
<p><code>String[]</code> is obviously *not* a subclass of <code>XMLEntityManager</code> therefore this call should not be allowed. If you check the bug reports I&#8217;m referring, it is clear that the JVM engineers are aware that this is a bug.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jing Xue</title>
		<link>http://dow.ngra.de/2008/11/03/when-protected-isnt-protected/comment-page-1/#comment-3108</link>
		<dc:creator>Jing Xue</dc:creator>
		<pubDate>Tue, 04 Nov 2008 15:56:43 +0000</pubDate>
		<guid isPermaLink="false">http://dow.ngra.de/?p=360#comment-3108</guid>
		<description>@Jevgeni,

Of course that&#039;s not going to compile, but that&#039;s governed by the Java _Language_ Spec, not the _JVM_ Spec, isn&#039;t it?

So if we stick to the JVM and the byte code, it does seem to me that INVOKEVIRTUAL is doing what it&#039;s supposed to do: dispatching to the right version at runtime, instead of going with whatever is nominally passed to it.</description>
		<content:encoded><![CDATA[<p>@Jevgeni,</p>
<p>Of course that&#8217;s not going to compile, but that&#8217;s governed by the Java _Language_ Spec, not the _JVM_ Spec, isn&#8217;t it?</p>
<p>So if we stick to the JVM and the byte code, it does seem to me that INVOKEVIRTUAL is doing what it&#8217;s supposed to do: dispatching to the right version at runtime, instead of going with whatever is nominally passed to it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: orip</title>
		<link>http://dow.ngra.de/2008/11/03/when-protected-isnt-protected/comment-page-1/#comment-3107</link>
		<dc:creator>orip</dc:creator>
		<pubDate>Tue, 04 Nov 2008 12:25:16 +0000</pubDate>
		<guid isPermaLink="false">http://dow.ngra.de/?p=360#comment-3107</guid>
		<description>Sneaky bug.
The JVM allows access to all members (incl. private and protected) through reflection - but at least that&#039;s done explicitly.</description>
		<content:encoded><![CDATA[<p>Sneaky bug.<br />
The JVM allows access to all members (incl. private and protected) through reflection &#8211; but at least that&#8217;s done explicitly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jevgeni Kabanov</title>
		<link>http://dow.ngra.de/2008/11/03/when-protected-isnt-protected/comment-page-1/#comment-3106</link>
		<dc:creator>Jevgeni Kabanov</dc:creator>
		<pubDate>Tue, 04 Nov 2008 11:45:26 +0000</pubDate>
		<guid isPermaLink="false">http://dow.ngra.de/?p=360#comment-3106</guid>
		<description>@Paul

Actually most often that&#039;s a terrible idea. Backwards-compatibility is very important, unless you want to get up at 3 AM because the production server doesn&#039;t work properly after the latest Java update.

My point is more that people who think that Java spec is all there is to Java are greatly oversimplifying things.</description>
		<content:encoded><![CDATA[<p>@Paul</p>
<p>Actually most often that&#8217;s a terrible idea. Backwards-compatibility is very important, unless you want to get up at 3 AM because the production server doesn&#8217;t work properly after the latest Java update.</p>
<p>My point is more that people who think that Java spec is all there is to Java are greatly oversimplifying things.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jevgeni Kabanov</title>
		<link>http://dow.ngra.de/2008/11/03/when-protected-isnt-protected/comment-page-1/#comment-3105</link>
		<dc:creator>Jevgeni Kabanov</dc:creator>
		<pubDate>Tue, 04 Nov 2008 11:42:28 +0000</pubDate>
		<guid isPermaLink="false">http://dow.ngra.de/?p=360#comment-3105</guid>
		<description>@Jing, @Tim

You are missing the point. If you write this code in Java it won&#039;t even compile:

&lt;pre&gt;
public String[] getRecognizedProperties() {
  return (String[])(((Object)   
    RPROPERTIES).clone());
}
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>@Jing, @Tim</p>
<p>You are missing the point. If you write this code in Java it won&#8217;t even compile:</p>
<pre>
public String[] getRecognizedProperties() {
  return (String[])(((Object)
    RPROPERTIES).clone());
}
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim</title>
		<link>http://dow.ngra.de/2008/11/03/when-protected-isnt-protected/comment-page-1/#comment-3100</link>
		<dc:creator>Tim</dc:creator>
		<pubDate>Tue, 04 Nov 2008 04:19:16 +0000</pubDate>
		<guid isPermaLink="false">http://dow.ngra.de/?p=360#comment-3100</guid>
		<description>The superclass of all array types is Object...</description>
		<content:encoded><![CDATA[<p>The superclass of all array types is Object&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul</title>
		<link>http://dow.ngra.de/2008/11/03/when-protected-isnt-protected/comment-page-1/#comment-3098</link>
		<dc:creator>Paul</dc:creator>
		<pubDate>Mon, 03 Nov 2008 17:52:11 +0000</pubDate>
		<guid isPermaLink="false">http://dow.ngra.de/?p=360#comment-3098</guid>
		<description>Sometimes, when an implementation bug like this occurs, a certain mass of code appears that depends upon it.

This causes  big problems when it comes time to fix it since it&#039;ll break existing code bases. I say, it&#039;s better to just fix things. Sometimes, we should just let go of backward compatibility.</description>
		<content:encoded><![CDATA[<p>Sometimes, when an implementation bug like this occurs, a certain mass of code appears that depends upon it.</p>
<p>This causes  big problems when it comes time to fix it since it&#8217;ll break existing code bases. I say, it&#8217;s better to just fix things. Sometimes, we should just let go of backward compatibility.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jing Xue</title>
		<link>http://dow.ngra.de/2008/11/03/when-protected-isnt-protected/comment-page-1/#comment-3097</link>
		<dc:creator>Jing Xue</dc:creator>
		<pubDate>Mon, 03 Nov 2008 16:13:55 +0000</pubDate>
		<guid isPermaLink="false">http://dow.ngra.de/?p=360#comment-3097</guid>
		<description>I rarely have to delve into byte code, so I&#039;m just commenting based on about 10 minutes of spec reading: :)

Invokevirtual does dispatching based on the runtime type of the target object. So where the byte code nominally shows INVOKEVIRTUAL Object.clone() : Object[], could it be that it&#039;s actually dispatching to Array[].clone()?

If that is true, then according to the JLS 6.4.5, the clone() method on all array types is actually public.

That might be one way to explain it. :)</description>
		<content:encoded><![CDATA[<p>I rarely have to delve into byte code, so I&#8217;m just commenting based on about 10 minutes of spec reading: :)</p>
<p>Invokevirtual does dispatching based on the runtime type of the target object. So where the byte code nominally shows INVOKEVIRTUAL Object.clone() : Object[], could it be that it&#8217;s actually dispatching to Array[].clone()?</p>
<p>If that is true, then according to the JLS 6.4.5, the clone() method on all array types is actually public.</p>
<p>That might be one way to explain it. :)</p>
]]></content:encoded>
	</item>
</channel>
</rss>

