Still posting on the very same problem...

While trying to close the gap between some working pet examples,
and the complete failing application, I come up with the following code
samples. The first one works perfectly, while the second one raises the
infamous "java.dyn.NoAccessException" that is beginning to cause me
a slight headache...

The only difference between the code samples is that the failing one
tries to use a method handle whose signature contains a user-defined
class. In particular, it should be noted that access qualifiers are strictly
the same in both code samples. Just in case someone is wondering,
making the "p.Param" class public do not solve the problem.

Working code sample:
        package p;

        import java.dyn.*;

        class Param {
        }

        class Aux {
            public static void greet(String s, Object p) { 
System.out.printf("hello %s.\n", s); }
        }

        public class Test {

            public static void main(final String[] args) throws Throwable {
                MethodType t = MethodType.methodType(void.class, String.class, 
Object.class);
                MethodHandle h = MethodHandles.lookup().findStatic(Aux.class, 
"greet", t);
                h.invokeGeneric("test", null);
            }

        }

Failing code sample:
        package p;

        import java.dyn.*;

        class Param {
        }

        class Aux {
            public static void greet(String s, Param p) { 
System.out.printf("hello %s.\n", s); }
        }

        public class Test {

            public static void main(final String[] args) throws Throwable {
                MethodType t = MethodType.methodType(void.class, String.class, 
Param.class);
                MethodHandle h = MethodHandles.lookup().findStatic(Aux.class, 
"greet", t);
                h.invokeGeneric("test", null);
            }

        }

Associated stack trace:
        Exception in thread "main" java.dyn.NoAccessException: cannot access: 
*.java.dyn.MethodHandle.invoke(java.lang.String,p.Param)void
                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:268)
                at sun.dyn.Invokers.exactInvoker(Invokers.java:66)
                at sun.dyn.Invokers.genericInvoker(Invokers.java:74)
                at java.dyn.MethodHandle.invokeGeneric(MethodHandle.java:273)
                at p.Test.main(Test.java:14)


Thanks again for your patience, dear list.
And thanks in advance to anyone able to shed some light on this problem.

Xavier Clerc

-- 
You received this message because you are subscribed to the Google Groups "JVM 
Languages" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/jvm-languages?hl=en.

Reply via email to