Source:
private Optional<MethodHandle> getConstructor(Method method, Optional<Constructor<?>> optionalConstructor) { if (isStatic(method.getModifiers())) { return Optional.empty(); } checkArgument(optionalConstructor.isPresent(), "Method [%s] is an instance method. It must be in a class annotated with @ScalarFunction, and the class is required to have a public constructor.", method); Constructor<?> constructor = optionalConstructor.get(); Set<TypeParameter> constructorTypeParameters = Stream.of(constructor.getAnnotationsByType(TypeParameter.class)) .collect(ImmutableSet.toImmutableSet()); checkArgument(constructorTypeParameters.containsAll(typeParameters), "Method [%s] is an instance method and requires a public constructor containing all type parameters: %s", method, typeParameters); for (int i = 0; i < constructor.getParameterCount(); i++) { Annotation[] annotations = constructor.getParameterAnnotations()[i]; checkArgument(containsImplementationDependencyAnnotation(annotations), "Constructors may only have meta parameters [%s]", constructor); checkArgument(annotations.length == 1, "Meta parameters may only have a single annotation [%s]", constructor); Annotation annotation = annotations[0]; if (annotation instanceof TypeParameter) { checkTypeParameters(parseTypeSignature(((TypeParameter) annotation).value()), typeParameterNames, method); } constructorDependencies.add(createDependency(annotation, literalParameters, null)); } MethodHandle result = constructorMethodHandle(FUNCTION_IMPLEMENTATION_ERROR, constructor); return Optional.of(result.asType(result.type().changeReturnType(Object.class))); }

Target:
private Optional<MethodHandle> getConstructor(Method method, Optional<Constructor<?>> optionalConstructor) { if (isStatic(method.getModifiers())) { return Optional.empty(); } checkArgument(optionalConstructor.isPresent(), "Method [%s] is an instance method. It must be in a class annotated with @ScalarFunction, and the class is required to have a public constructor.", method); Constructor<?> constructor = optionalConstructor.get(); Set<TypeParameter> constructorTypeParameters = Stream.of(constructor.getAnnotationsByType(TypeParameter.class)) .collect(ImmutableSet.toImmutableSet()); checkArgument(constructorTypeParameters.containsAll(typeParameters), "Method [%s] is an instance method and requires a public constructor containing all type parameters: %s", method, typeParameters); for (int i = 0; i < constructor.getParameterCount(); i++) { Annotation[] annotations = constructor.getParameterAnnotations()[i]; checkArgument(containsImplementationDependencyAnnotation(annotations), "Constructors may only have meta parameters [%s]", constructor); checkArgument(annotations.length == 1, "Meta parameters may only have a single annotation [%s]", constructor); Annotation annotation = annotations[0]; if (annotation instanceof TypeParameter) { checkTypeParameters(parseTypeSignature(((TypeParameter) annotation).value()), typeParameterNames, method); } constructorDependencies.add(createDependency(annotation, literalParameters)); } MethodHandle result = constructorMethodHandle(FUNCTION_IMPLEMENTATION_ERROR, constructor); return Optional.of(result.asType(result.type().changeReturnType(Object.class))); }