1.1 --- a/src/jdk/internal/dynalink/beans/StaticClassLinker.java Wed Jul 03 14:08:00 2013 +0530 1.2 +++ b/src/jdk/internal/dynalink/beans/StaticClassLinker.java Wed Jul 03 12:39:28 2013 +0200 1.3 @@ -87,9 +87,7 @@ 1.4 import java.lang.invoke.MethodHandles; 1.5 import java.lang.invoke.MethodType; 1.6 import java.lang.reflect.Array; 1.7 -import java.lang.reflect.Constructor; 1.8 -import java.util.ArrayList; 1.9 -import java.util.List; 1.10 +import java.util.Arrays; 1.11 import jdk.internal.dynalink.CallSiteDescriptor; 1.12 import jdk.internal.dynalink.beans.GuardedInvocationComponent.ValidationType; 1.13 import jdk.internal.dynalink.linker.GuardedInvocation; 1.14 @@ -131,20 +129,11 @@ 1.15 private static DynamicMethod createConstructorMethod(Class<?> clazz) { 1.16 if(clazz.isArray()) { 1.17 final MethodHandle boundArrayCtor = ARRAY_CTOR.bindTo(clazz.getComponentType()); 1.18 - return new SimpleDynamicMethod(drop(boundArrayCtor.asType(boundArrayCtor.type().changeReturnType( 1.19 - clazz))), clazz, "<init>"); 1.20 + return new SimpleDynamicMethod(StaticClassIntrospector.editConstructorMethodHandle( 1.21 + boundArrayCtor.asType(boundArrayCtor.type().changeReturnType(clazz))), clazz, "<init>"); 1.22 } 1.23 1.24 - final Constructor<?>[] ctrs = clazz.getConstructors(); 1.25 - final List<MethodHandle> mhs = new ArrayList<>(ctrs.length); 1.26 - for(int i = 0; i < ctrs.length; ++i) { 1.27 - mhs.add(drop(SafeUnreflector.unreflectConstructor(ctrs[i]))); 1.28 - } 1.29 - return createDynamicMethod(mhs, clazz, "<init>"); 1.30 - } 1.31 - 1.32 - private static MethodHandle drop(MethodHandle mh) { 1.33 - return StaticClassIntrospector.dropReceiver(mh, StaticClass.class); 1.34 + return createDynamicMethod(Arrays.asList(clazz.getConstructors()), clazz, "<init>"); 1.35 } 1.36 1.37 @Override 1.38 @@ -161,11 +150,10 @@ 1.39 } 1.40 final CallSiteDescriptor desc = request.getCallSiteDescriptor(); 1.41 final String op = desc.getNameToken(CallSiteDescriptor.OPERATOR); 1.42 - final MethodType methodType = desc.getMethodType(); 1.43 if("new" == op && constructor != null) { 1.44 - final MethodHandle ctorInvocation = constructor.getInvocation(methodType, linkerServices); 1.45 + final MethodHandle ctorInvocation = constructor.getInvocation(desc, linkerServices); 1.46 if(ctorInvocation != null) { 1.47 - return new GuardedInvocation(ctorInvocation, getClassGuard(methodType)); 1.48 + return new GuardedInvocation(ctorInvocation, getClassGuard(desc.getMethodType())); 1.49 } 1.50 } 1.51 return null;