Iulian Dragos a écrit : > I noticed several differences between what JSR 292 > (http://jcp.org/en/jsr/detail?id=292) says and the current > implementation. I know this is work in progress, but at least one > difference seems small enough to be an oversight. > Currently, the first draft of the spec is outdated and the implemntation is not up to date too.
> The signature of the bootstrap method is defined as Object(CallSite > cs, Object... args) in code, but the JSR lists it as Object(CallSite > cs, Object receiver, Object... args). The latter has a great > advantage: the arguments are already prepared for a reflective call. > The current idea is to implement invokedynamic like invokestatic, i.e without a receiver. > The contract of 'bootstrap' is that it makes the call and returns a > value, possibly setting a target for future calls. In the current > implementation, one would have to create a new array and strip the > first element: > > cs.setTarget(mh); > Object[] args1 = new Object[args.length - 1]; > System.arraycopy(args, 1, args1, 0, args.length - 1); > return rm.invoke(args[0], args1); > > I find this to be a typical scenario, so I wonder why this deviation > from the JSR. > The spec is outdated. > A second question: Is there a way to invoke a method handle > generically? That means by passing an Object array, as done above > using java.lang.reflect.Method. In other words, could method handles > be used in the bootstrap method instead of reflect.Method? > You can directly call a MethodHandle without put object in a array by calling a invoke method with any arguments you want: MethodHandle mh=... mh.invoke(3,"foo"); // here 3 is not boxed > Thanks, > Iulia Rémi _______________________________________________ mlvm-dev mailing list [email protected] http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev
