Bug in catchException()

John Rose John.Rose at Sun.COM
Tue Sep 8 15:15:15 PDT 2009


The root cause is a known bug. One workaround is to put your app.  
classes on the boot CP. The bug happens when app. class  names appear  
in signatures of methods referred to by direct MHs or by MH.invoke.   
The 292 runtime shouldn't be using such a signature, I think, so  
there's another bug. Thanks for the report.

-- John  (on my iPhone)

On Sep 4, 2009, at 1:57 AM, Attila Szegedi <szegedia at gmail.com> wrote:

> Hi folks,
>
> This small testcase fails in MethodHandles.catchException() on MLVM:
>
> import java.dyn.MethodHandle;
> import java.dyn.MethodHandles;
> import java.dyn.MethodType;
>
> public class TestCatchException
> {
>     public static void main(String[] args) throws Throwable
>     {
>         MethodHandle throwing = findStatic("throwing");
>         MethodHandle catching = findStatic("catching");
>         MethodHandles.catchException(throwing, MyException.class,
>                 MethodHandles.dropArguments(catching, 0,
>                         MyException.class));
>     }
>
>     private static class MyException extends RuntimeException
>     {
>     }
>
>     private static MethodHandle findStatic(String name)
>     {
>         return MethodHandles.publicLookup().findStatic(
>                 TestCatchException.class, name,
> MethodType.make(int.class,
>                         Object.class));
>     }
>
>
>     public static int throwing(Object o)
>     {
>         throw new MyException();
>     }
>
>     public static int catching(Object o)
>     {
>         return 0;
>     }
> }
>
> Notably, it fails with:
>
> Exception in thread "main" java.dyn.NoAccessException: cannot access:
> *.java.dyn.MethodHandle.invoke(TestCatchException
> $MyException,java.lang.Object)int
>    at sun.dyn.MemberName.newNoAccessException(MemberName.java:421)
>    at sun.dyn.MemberName.newNoAccessException(MemberName.java:412)
>    at sun.dyn.MemberName$Factory.resolveOrFail(MemberName.java:517)
>    at java.dyn.MethodHandles$Lookup.findVirtual(MethodHandles.java: 
> 267)
>    at sun.dyn.Invokers.exactInvoker(Invokers.java:66)
>    at java.dyn.MethodHandles.exactInvoker(MethodHandles.java:761)
>    at sun.dyn.FromGeneric.computeUnboxingInvoker(FromGeneric.java:137)
>    at sun.dyn.FromGeneric.makeInstance(FromGeneric.java:160)
>    at sun.dyn.FromGeneric.make(FromGeneric.java:174)
>    at sun.dyn.MethodHandleImpl.convertArguments 
> (MethodHandleImpl.java:460)
>    at sun.dyn.MethodHandleImpl.makeGuardWithCatch 
> (MethodHandleImpl.java:
> 840)
>    at java.dyn.MethodHandles.catchException(MethodHandles.java:1397)
>    at TestCatchException.main(TestCatchException.java:12)
>
> However, if I replace "MyException" with an exception on the boot
> classpath, i.e. IllegalArgumentException, then catchException() will
> succeed. Any advice for a workaround?
>
> Attila.
> _______________________________________________
> 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