<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div><font class="Apple-style-span" size="4"><span class="Apple-style-span" style="font-size: 14px;">On May 26, 2011, at 10:11 AM, Tom Rodriguez wrote:</span></font></div><font class="Apple-style-span" size="4"><span class="Apple-style-span" style="font-size: 14px;"><br class="Apple-interchange-newline"></span></font><blockquote type="cite"><div><font class="Apple-style-span" size="4"><span class="Apple-style-span" style="font-size: 14px;">isValid looks fine.<br></span></font></div></blockquote></div><font class="Apple-style-span" size="4"><span class="Apple-style-span" style="font-size: 14px;"><br></span></font><div><font class="Apple-style-span" size="4"><span class="Apple-style-span" style="font-size: 14px;">Thanks Tom. &nbsp;I also corrected the javadoc, added a demo of isValid and copied the javadoc example into the unit tests.</span></font></div><div><font class="Apple-style-span" size="4"><span class="Apple-style-span" style="font-size: 14px;"><br></span></font></div><div><font class="Apple-style-span" size="4"><span class="Apple-style-span" style="font-size: 14px;">-- John</span></font></div><div><font class="Apple-style-span" size="4"><span class="Apple-style-span" style="font-size: 14px;"><br></span></font></div><div><span class="Apple-style-span" style="font-family: 'Lucida Sans Typewriter'; font-size: 12px; ">diff --git a/src/share/classes/java/lang/invoke/SwitchPoint.java b/src/share/classes/java/lang/invoke/SwitchPoint.java</span></div><div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">--- a/src/share/classes/java/lang/invoke/SwitchPoint.java</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">+++ b/src/share/classes/java/lang/invoke/SwitchPoint.java</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">@@ -56,16 +56,17 @@</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">&nbsp;&nbsp;* &lt;p&gt;</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">&nbsp;&nbsp;* Here is an example of a switch point in action:</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">&nbsp;&nbsp;* &lt;blockquote&gt;&lt;pre&gt;</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">-MethodType MT_str2 = MethodType.methodType(String.class, String.class);</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">&nbsp;MethodHandle MH_strcat = MethodHandles.lookup()</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">- &nbsp; &nbsp;.findVirtual(String.class, "concat", MT_str2);</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">+ &nbsp; &nbsp;.findVirtual(String.class, "concat", MethodType.methodType(String.class, String.class));</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">&nbsp;SwitchPoint spt = new SwitchPoint();</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">+assert(spt.isValid());</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">&nbsp;// the following steps may be repeated to re-use the same switch point:</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">-MethodHandle worker1 = strcat;</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">-MethodHandle worker2 = MethodHandles.permuteArguments(strcat, MT_str2, 1, 0);</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">+MethodHandle worker1 = MH_strcat;</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">+MethodHandle worker2 = MethodHandles.permuteArguments(MH_strcat, MH_strcat.type(), 1, 0);</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">&nbsp;MethodHandle worker = spt.guardWithTest(worker1, worker2);</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">&nbsp;assertEquals("method", (String) worker.invokeExact("met", "hod"));</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">&nbsp;SwitchPoint.invalidateAll(new SwitchPoint[]{ spt });</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">+assert(!spt.isValid());</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">&nbsp;assertEquals("hodmet", (String) worker.invokeExact("met", "hod"));</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">&nbsp;&nbsp;* &lt;/pre&gt;&lt;/blockquote&gt;</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">&nbsp;&nbsp;* &lt;p style="font-size:smaller;"&gt;</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">diff --git a/test/java/lang/invoke/JavaDocExamplesTest.java b/test/java/lang/invoke/JavaDocExamplesTest.java</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">--- a/test/java/lang/invoke/JavaDocExamplesTest.java</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">+++ b/test/java/lang/invoke/JavaDocExamplesTest.java</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">@@ -471,6 +471,25 @@</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }}</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">&nbsp;&nbsp; &nbsp; }</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">&nbsp;</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">+ &nbsp; &nbsp;@Test public void testSwitchPoint() throws Throwable {</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">+ &nbsp; &nbsp; &nbsp; &nbsp;{{</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">+{} /// JAVADOC</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">+MethodHandle MH_strcat = MethodHandles.lookup()</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">+ &nbsp; &nbsp;.findVirtual(String.class, "concat", MethodType.methodType(String.class, String.class));</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">+SwitchPoint spt = new SwitchPoint();</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">+assert(spt.isValid());</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">+// the following steps may be repeated to re-use the same switch point:</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">+MethodHandle worker1 = MH_strcat;</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">+MethodHandle worker2 = MethodHandles.permuteArguments(MH_strcat, MH_strcat.type(), 1, 0);</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">+MethodHandle worker = spt.guardWithTest(worker1, worker2);</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">+assertEquals("method", (String) worker.invokeExact("met", "hod"));</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">+SwitchPoint.invalidateAll(new SwitchPoint[]{ spt });</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">+assert(!spt.isValid());</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">+assertEquals("hodmet", (String) worker.invokeExact("met", "hod"));</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">+{}</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}}</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">+ &nbsp; &nbsp;}</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">+</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">&nbsp;&nbsp; &nbsp; /* ---- TEMPLATE ----</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">&nbsp;&nbsp; &nbsp; @Test public void testFoo() throws Throwable {</span></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'" size="3"><span class="Apple-style-span" style="font-size: 12px;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; {{</span></font></div></div><div><br></div></body></html>