I had tried that before; when I do that, I get:<div><br></div><div><div>Exception in thread &quot;main&quot; java.dyn.WrongMethodTypeException: Bound[&lt;unknown&gt;(java.lang.String)java.lang.String]</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>at java.dyn.CallSite.checkTarget(CallSite.java:149)</div>

<div><span class="Apple-tab-span" style="white-space:pre">        </span>at java.dyn.CallSite.setTarget(CallSite.java:142)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>at Main$MissingHandle.&lt;init&gt;(Main.java:29)</div>

<div><span class="Apple-tab-span" style="white-space:pre">        </span>at Main.bootstrapDynamic(Main.java:46)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>at sun.dyn.CallSiteImpl.makeSite(CallSiteImpl.java:64)</div>

<div><span class="Apple-tab-span" style="white-space:pre">        </span>at Main.main(Main.java:15)</div><div><br></div><div>-- Yehuda</div><br><div class="gmail_quote">On Mon, May 18, 2009 at 2:05 PM, John Rose <span dir="ltr">&lt;<a href="mailto:John.Rose@sun.com">John.Rose@sun.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div style="word-wrap:break-word">Thanks for giving it a spin.  Your test case is a good one, but there seem to be logic errors.<div>

<br></div><div>This line:</div><div><span style="font-family:Monaco;line-height:16px"><pre style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;line-height:1.4em;font-family:&#39;Bitstream Vera Sans Mono&#39;, Courier, monospace">

<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:1em;line-height:1.4em"><span style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;line-height:1.4em">site</span><span style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;line-height:1.4em;font-weight:bold">.</span><span style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;line-height:1.4em;color:rgb(0, 128, 128)">setTarget</span><span style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;line-height:1.4em;font-weight:bold">(</span><span style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;line-height:1.4em">target</span><span style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;line-height:1.4em;font-weight:bold">);</span></div>

</pre></span><div>should probably be</div><div><span style="font-family:Monaco;line-height:16px"><pre style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;line-height:1.4em;font-family:&#39;Bitstream Vera Sans Mono&#39;, Courier, monospace">

<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:1em;line-height:1.4em"><span style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;line-height:1.4em">site</span><span style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;line-height:1.4em;font-weight:bold">.</span><span style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;line-height:1.4em;color:rgb(0, 128, 128)">setTarget</span><span style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;line-height:1.4em;font-weight:bold">(</span><span style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;line-height:1.4em">this</span><span style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;line-height:1.4em;font-weight:bold">);</span></div>

<div><b><br></b></div></pre></span></div><div>I&#39;m surprised you don&#39;t get an error at that point.  Your target takes 2 string args, while the indy site takes just one.  I think the call to CallSite.checkTarget should be throwing an error at this point.   (This is also where static typing would help.)</div>

<div><br></div><div>The crash happens, perhaps, because the JVM is trying to raise a WrongMethodType and the assembly code has left the stack a little bit off-balance.  Our error-reporting paths need work.  (ASAP, since this will be lots of people&#39;s experience!)</div>

<div><br></div><div>It is probably good style to close the CallSite into the &quot;method not found&quot; handler, but in that case you don&#39;t need to redundantly close in the CallSite.name.</div><div><br></div><div>Thanks!</div>

<div><br></div><font color="#888888"><div>-- John</div></font><div><div></div><div class="h5"><div><br><div><div>On May 18, 2009, at 1:25 PM, Yehuda Katz wrote:</div><br><blockquote type="cite">I&#39;m trying to implement a simple method missing using invokeDynamic. I&#39;ve been able to make it work using static methods or static methods that proxy to virtual methods (but not directly to virtual methods). However, I&#39;m trying to add support for including the name of the method in the call to MethodMissing.<div>

 <br></div><div>Based on the Fidget demo, it seemed like the way to go would be to create a custom JavaMethodHandle that encapsulated the logic. I wasn&#39;t able to get it working (mostly in the setTarget step). However, during some experiments, I encountered a segfault in the JVM, so I figured I&#39;d report it. The details (including the minimal test case) are at <a href="http://gist.github.com/113717" target="_blank">http://gist.github.com/113717</a>.</div>

 <div><br></div><div>That said, I&#39;m curious about the appropriate way to wire this up. I&#39;m rather new to all of this, so I&#39;m probably missing something obvious.<br clear="all"></div></blockquote></div><br></div>

</div></div></div></div>
<br>_______________________________________________<br>
mlvm-dev mailing list<br>
<a href="mailto:mlvm-dev@openjdk.java.net">mlvm-dev@openjdk.java.net</a><br>
<a href="http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev" target="_blank">http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Yehuda Katz<br>Developer | Engine Yard<br>(ph) 718.877.1325<br>
</div>