Jim's example works on 7u2 for me as well.
The cast is not without effect at all. It is crucial to have it!
That is because of the so called "Signature polymorphism" of the
'invokeExact()' and plain 'invoke()' methods (read the API
documentation for more details:
http://docs.oracle.com/javase/7/d
As soon as you mh = mh.asType(target); it is no longer vararg, so it is
treating new Class[0] as the second argument cast to Object. If you are trying
to type as (Object , Object[]). I think you are going to run into difficulties
validating (Class[]) Object[]. You may have to add a wrapper to
Am 07.02.2012 18:29, schrieb Jim Laskey:
> Worked okay for me. So must be addressed in a later release. :-/
later than jdk7u2? oh boy. I would feel better if I could find a bug
report that shows the problem and that is resolved. Then I would at
least have something for the release notes. But I
Worked okay for me. So must be addressed in a later release. :-/
On 2012-02-07, at 1:17 PM, Jochen Theodorou wrote:
>
> That will produce a
>
> java.lang.invoke.WrongMethodTypeException:
> (Ljava/lang/Object;[Ljava/lang/Object;)V cannot be called without a receiver
> argument as ([Ljava/l
That will produce a
java.lang.invoke.WrongMethodTypeException:
(Ljava/lang/Object;[Ljava/lang/Object;)V cannot be called without a
receiver argument as ([Ljava/lang/Object;)Ljava/lang/Object;
imho casting to Object and Object[] in
mh.invokeExact((Object)Class.class, (Object[])new Class[0]);
Try
MethodType type = MethodType.methodType(Constructor.class,
Class[].class);
MethodHandle mh = MethodHandles.lookup().findVirtual(Class.class,
"getDeclaredConstructor", type);
MethodType target = MethodType.methodType(void.class, Object.class,
Object[].class);
mh =
Am 07.02.2012 17:29, schrieb Jim Laskey:
MethodType type = MethodType.methodType(Constructor.class,
Class[].class);
MethodHandle mh = MethodHandles.lookup().findVirtual(Class.class,
"getDeclaredConstructor", type);
MethodType target = MethodType.me
As soon as you mh = mh.asType(target); it is no longer vararg, so it is
treating new Class[0] as the second argument cast to Object. If you are trying
to type as (Object , Object[]). I think you are going to run into difficulties
validating (Class[]) Object[]. You may have to add a wrapper to
As soon as you mh = mh.asType(target); it is no longer vararg, so it is
treating new Class[0] as the second argument cast to Object. If you are trying
to type as (Object , Object[]). I think you are going to run into difficulties
validating (Class[]) Object[]. You may have to add a wrapper to
The problem can be easily reproduced using this:
> MethodType type = MethodType.methodType(Constructor.class,
> Class[].class);
> MethodHandle mh = MethodHandles.lookup().findVirtual(Class.class,
> "getDeclaredConstructor", type);
> MethodType target = MethodType.methodTyp
Hi all,
maybe someone can explain to me why method handles behave this way in my
case.
Bascially I have a handle for Class#getDeclaredConstructor(Class...) I
created via unreflect.
http://docs.oracle.com/javase/7/docs/api/java/lang/Class.html#getDeclaredConstructor%28java.lang.Class...%29
thi
11 matches
Mail list logo