Dear list,
I have just started playing with classes from the "java.dyn" package and am
a bit puzzled about the exact causes of a "java.dyn.NoAccessException"
exception.
At some point, a "java.dyn.MethodHandle" is built from a
"java.lang.reflect.Method"
instance, and later "invokeGeneric(-)" is called on this very handle. This
works as
expected on the tiny sample code reproduced at the end of this mail, but fails
in
the whole application. The thing that puzzles me is that before the changes I
used
the classical reflection and "invoke(-)" on the "java.lang.reflect.Method"
instance
with no problem. This would lead me to the conclusion that there should be no
access problem.
Thus, at the end of day, my question is the following: is there any difference
between
"java.lang.reflect.Method" and "java.dyn.MethodHandle" concerning access checks
for an invocation ? The only bit of information about access checks I was able
to find
just states that checks are done at creation time rather than at invocation
time.
This reinforces my difficulties to understand how a properly created handle
could
actually raise an access exception at invocation.
For the record, I should state that I use the build labeled
"java-1.7.0-internal-2010_03_07"
for MacOS X under Snow Leopard.
Thanks for any hint,
Xavier Clerc
---
package p;
import java.dyn.*;
import java.lang.reflect.*;
public class T {
public static void greet(String s) { System.out.printf("hello %s.\n",
s); }
public static void main(String[] args) throws Throwable {
Method m = T.class.getMethod("greet", String.class);
MethodHandle h = MethodHandles.lookup().unreflect(m);
h.invokeGeneric("first");
}
}
--
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.