Java Doc Bugs
John Rose
john.r.rose at oracle.com
Fri Aug 13 23:44:45 PDT 2010
Thanks, Howard. Will fix in next push.
I changed the example to use the "assertEquals" function from JUnit:
MethodHandle cat = lookup().findVirtual(String.class,
"concat", methodType(String.class, String.class));
assertEquals("xy", (String) cat.invokeExact("x", "y"));
MethodHandle d0 = dropArguments(cat, 0, String.class);
assertEquals("yz", (String) d0.invokeExact("x", "y", "z"));
MethodHandle d1 = dropArguments(cat, 1, String.class);
assertEquals("xz", (String) d1.invokeExact("x", "y", "z"));
MethodHandle d2 = dropArguments(cat, 2, String.class);
assertEquals("xy", (String) d2.invokeExact("x", "y", "z"));
MethodHandle d12 = dropArguments(cat, 1, int.class, boolean.class);
assertEquals("xz", (String) d12.invokeExact("x", 12, true, "z"));
I'll probably do something similar to the other code examples, and fold them all into a JDK unit test.
-- John
On Aug 13, 2010, at 11:11 PM, Howard Lovatt wrote:
> There are some minor Java Doc Bugs in:
>
> http://cr.openjdk.java.net/~jrose/pres/indy-javadoc-mlvm/
>
> In particular the Java Doc for:
>
> MethodHandles.dropArguments
>
> The example given is incorrect and should be something like:
>
> final MethodType types = MethodType.methodType( String.class,
> String.class );
> final MethodHandle cat = lookup().findVirtual( String.class,
> "concat", types );
> System.out.println( cat.<String>invokeExact( "x", "y" ) ); // xy
> final MethodHandle d0 = dropArguments( cat, 0, String.class );
> System.out.println( d0.<String>invokeExact( "x", "y", "z" ) ); // yz
> final MethodHandle d1 = dropArguments( cat, 1, String.class );
> System.out.println( d1.<String>invokeExact( "x", "y", "z" ) ); // xz
> final MethodHandle d2 = dropArguments( cat, 2, String.class );
> System.out.println( d2.<String>invokeExact( "x", "y", "z" ) ); // xy
> final MethodHandle d12 = dropArguments( cat, 1, String.class,
> String.class );
> System.out.println( d12.<String>invokeExact( "w", "x", "y", "z" ) ); // wz
>
> There are some detail changes in the above but the most important
> thing is that the comments given as the output are corrected (the
> original comments implied numbering of arguments in reverse order).
>
> -- Howard.
> _______________________________________________
> mlvm-dev mailing list
> mlvm-dev at openjdk.java.net
> http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev
More information about the mlvm-dev
mailing list