162 */ |
162 */ |
163 public static MethodHandle getConstructor(final Class<?> sourceType, final Class<?> targetType, final MethodHandles.Lookup lookup) throws Exception { |
163 public static MethodHandle getConstructor(final Class<?> sourceType, final Class<?> targetType, final MethodHandles.Lookup lookup) throws Exception { |
164 final StaticClass adapterClass = getAdapterClassFor(new Class<?>[] { targetType }, null, lookup); |
164 final StaticClass adapterClass = getAdapterClassFor(new Class<?>[] { targetType }, null, lookup); |
165 return MH.bindTo(Bootstrap.getLinkerServices().getGuardedInvocation(new LinkRequestImpl( |
165 return MH.bindTo(Bootstrap.getLinkerServices().getGuardedInvocation(new LinkRequestImpl( |
166 NashornCallSiteDescriptor.get(lookup, "dyn:new", |
166 NashornCallSiteDescriptor.get(lookup, "dyn:new", |
167 MethodType.methodType(targetType, StaticClass.class, sourceType), 0), false, |
167 MethodType.methodType(targetType, StaticClass.class, sourceType), 0), null, false, |
168 adapterClass, null)).getInvocation(), adapterClass); |
168 adapterClass, null)).getInvocation(), adapterClass); |
169 } |
169 } |
170 |
170 |
171 /** |
171 /** |
172 * Returns whether an instance of the specified class/interface can be generated from a ScriptFunction. Returns true |
172 * Returns whether an instance of the specified class/interface can be generated from a ScriptFunction. Returns true |