--- a/nashorn/src/jdk/internal/dynalink/beans/StaticClassLinker.java Wed Jul 03 14:08:00 2013 +0530
+++ b/nashorn/src/jdk/internal/dynalink/beans/StaticClassLinker.java Wed Jul 03 12:39:28 2013 +0200
@@ -87,9 +87,7 @@
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.lang.reflect.Array;
-import java.lang.reflect.Constructor;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.Arrays;
import jdk.internal.dynalink.CallSiteDescriptor;
import jdk.internal.dynalink.beans.GuardedInvocationComponent.ValidationType;
import jdk.internal.dynalink.linker.GuardedInvocation;
@@ -131,20 +129,11 @@
private static DynamicMethod createConstructorMethod(Class<?> clazz) {
if(clazz.isArray()) {
final MethodHandle boundArrayCtor = ARRAY_CTOR.bindTo(clazz.getComponentType());
- return new SimpleDynamicMethod(drop(boundArrayCtor.asType(boundArrayCtor.type().changeReturnType(
- clazz))), clazz, "<init>");
+ return new SimpleDynamicMethod(StaticClassIntrospector.editConstructorMethodHandle(
+ boundArrayCtor.asType(boundArrayCtor.type().changeReturnType(clazz))), clazz, "<init>");
}
- final Constructor<?>[] ctrs = clazz.getConstructors();
- final List<MethodHandle> mhs = new ArrayList<>(ctrs.length);
- for(int i = 0; i < ctrs.length; ++i) {
- mhs.add(drop(SafeUnreflector.unreflectConstructor(ctrs[i])));
- }
- return createDynamicMethod(mhs, clazz, "<init>");
- }
-
- private static MethodHandle drop(MethodHandle mh) {
- return StaticClassIntrospector.dropReceiver(mh, StaticClass.class);
+ return createDynamicMethod(Arrays.asList(clazz.getConstructors()), clazz, "<init>");
}
@Override
@@ -161,11 +150,10 @@
}
final CallSiteDescriptor desc = request.getCallSiteDescriptor();
final String op = desc.getNameToken(CallSiteDescriptor.OPERATOR);
- final MethodType methodType = desc.getMethodType();
if("new" == op && constructor != null) {
- final MethodHandle ctorInvocation = constructor.getInvocation(methodType, linkerServices);
+ final MethodHandle ctorInvocation = constructor.getInvocation(desc, linkerServices);
if(ctorInvocation != null) {
- return new GuardedInvocation(ctorInvocation, getClassGuard(methodType));
+ return new GuardedInvocation(ctorInvocation, getClassGuard(desc.getMethodType()));
}
}
return null;