/* (non-Javadoc)
@see groovy.lang.MetaClassImpl#invokeConstructor(java.lang.Object[])
165121
public Object invokeConstructor(Object[] arguments) {

        // TODO This is the only area where this MetaClass needs to do some interception because Groovy's current
        // MetaClass uses hard coded references to the java.lang.reflect.Constructor class so you can't simply
        // inject Constructor like you can do properties, methods and fields. When Groovy's MetaClassImpl is
        // refactored we can fix this
        Class[] argClasses = MetaClassHelper.convertToTypeArray(arguments);
        MetaMethod method = pickMethod(GROOVY_CONSTRUCTOR, argClasses);
        if (method != null && method.getParameterTypes().length == arguments.length) {
            return method.invoke(theClass, arguments);
        }
        return super.invokeConstructor(arguments);
    }
960319
public MethodInfo[] getConstructors() {
        int size = mMethods.size();
        List<MethodInfo> ctorsOnly = new ArrayList<MethodInfo>(size);

        for (int i=0; i<size; i++) {
            MethodInfo method = mMethods.get(i);
            if ("<init>".equals(method.getName())) {
                ctorsOnly.add(method);
            }
        }

        MethodInfo[] ctorsArray = new MethodInfo[ctorsOnly.size()];
        return ctorsOnly.toArray(ctorsArray);
    }
1185920
public Object invoke(MethodInvocation invocation) throws Throwable {
		ProxyMethodInvocation pmi = (ProxyMethodInvocation) invocation;
		TargetMetaRequest targetMetaRequest = targetMetaRequestsHolder.getTargetMetaRequest();
		TargetMetaDef targetMetaDef = targetMetaRequest.getTargetMetaDef();
		if (targetMetaDef.isEJB())
			return invocation.proceed();

		if (!isStateful(targetMetaDef)) {
			// Debug.logVerbose("[JdonFramework] target service is not Stateful: "
			// + targetMetaDef.getClassName() +
			// " StatefulInterceptor unactiive", module);
			return invocation.proceed();
		}
		Debug.logVerbose("[JdonFramework] enter StatefulInterceptor", module);
		Object result = null;
		try {
			ComponentVisitor cm = targetMetaRequest.getComponentVisitor();
			targetMetaRequest.setVisitableName(ComponentKeys.TARGETSERVICE_FACTORY);
			Debug.logVerbose(ComponentKeys.TARGETSERVICE_FACTORY + " in action (Stateful)", module);
			Object targetObjRef = cm.visit();
			pmi.setThis(targetObjRef);
			result = invocation.proceed();
		} catch (Exception ex) {
			Debug.logError("[JdonFramework]StatefulInterceptor error: " + ex, module);
		}
		return result;
	}
957976
@Override
    public Object invoke(Object[] vals) {
        try {
            if (isStatic()) {
                return field.get(null);
            } else {
                return field.get(vals[0]);
            }
        } catch (IllegalArgumentException e) {
            throw e;
        } catch (IllegalAccessException e) {
            // constructor should prevent this
            throw new RuntimeException("can't access field");
        }
    }
447805
private void createInstanceUsingConstructor() throws InvocationTargetException {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        if (isTraceOn && tc.isEntryEnabled())
            Tr.entry(tc, "createInstanceUsingConstructor");

        try {
            if (isTraceOn && tc.isDebugEnabled())
                Tr.debug(tc, "calling Constructor.newInstance");
            Constructor<?> con = home.beanMetaData.getEnterpriseBeanClassConstructor();
            setEnterpriseBean(con.newInstance());
        } catch (InvocationTargetException e) {
            FFDCFilter.processException(e, CLASS_NAME + ".createInstanceUsingConstructor", "360", this);
            throw e;
        } catch (Exception e) {
            // Reflection exceptions are unexpected.
            FFDCFilter.processException(e, CLASS_NAME + ".createInstanceUsingConstructor", "364", this);
            throw new EJBException(home.beanMetaData.enterpriseBeanClassName, e);
        }

        if (isTraceOn && tc.isEntryEnabled())
            Tr.exit(tc, "createInstanceUsingConstructor");
    }
1336729
private void transformConstructor(ConstructorNode ctor, boolean isAic) {
        boolean chainedThisConstructorCall = false;
        ConstructorCallExpression cce = null;
        if (ctor.firstStatementIsSpecialConstructorCall()) {
            Statement code = ctor.getFirstStatement();
            cce = (ConstructorCallExpression) ((ExpressionStatement) code).getExpression();
            if (cce.isSuperCall()) return;
            // must be call to this(...)
            chainedThisConstructorCall = true;
        }
        // we need to add parameters
        Parameter[] oldP = ctor.getParameters();
        Parameter[] newP = new Parameter[oldP.length + 2];
        String stringParameterName = getUniqueVariableName("__str", ctor.getCode());
        newP[0] = new Parameter(ClassHelper.STRING_TYPE, stringParameterName);
        String intParameterName = getUniqueVariableName("__int", ctor.getCode());
        newP[1] = new Parameter(ClassHelper.int_TYPE, intParameterName);
        System.arraycopy(oldP, 0, newP, 2, oldP.length);
        ctor.setParameters(newP);
        VariableExpression stringVariable = new VariableExpression(newP[0]);
        VariableExpression intVariable = new VariableExpression(newP[1]);
        if (chainedThisConstructorCall) {
            TupleExpression args = (TupleExpression) cce.getArguments();
            List<Expression> argsExprs = args.getExpressions();
            argsExprs.add(0, stringVariable);
            argsExprs.add(1, intVariable);
        } else {
            // add a super call
            List<Expression> args = new ArrayList<Expression>();
            args.add(stringVariable);
            args.add(intVariable);
            if (isAic) {
                for (Parameter parameter : oldP) {
                    args.add(new VariableExpression(parameter.getName()));
                }
            }
            cce = new ConstructorCallExpression(ClassNode.SUPER, new ArgumentListExpression(args));
            BlockStatement code = new BlockStatement();
            code.addStatement(new ExpressionStatement(cce));
            Statement oldCode = ctor.getCode();
            if (oldCode != null) code.addStatement(oldCode);
            ctor.setCode(code);
        }
    }
1157396
@SuppressWarnings("unchecked")
	public List<Constructor<T>> reflectAllConstructors() {
		return (List) Arrays.asList(clazz.getDeclaredConstructors());
	}
175949
private function invokeConstructorIfDeclared(array $arguments)
    {
        $methodName = 'construct';

        try {
            $method = new ReflectionMethod($this, $methodName);

            if (true === $method->isPublic()) {
                throw new RuntimeException(
                    'The constructor of an enumeration type may not be public.'
                );
            }

            $method->setAccessible(true);
            $method->invokeArgs($this, $arguments);
        } catch (ReflectionException $ex) {
            // empty block.
        }
    }
875642
private void generateConstructor(
      ImmutableMap<TemplateParam, SoyExpression> defaultParamInitializers) {
    final Label start = new Label();
    final Label end = new Label();
    final LocalVariable thisVar = createThisVar(template.typeInfo(), start, end);
    final LocalVariable paramsVar = createLocal("params", 1, SOY_RECORD_TYPE, start, end);
    final LocalVariable ijVar = createLocal("ij", 2, SOY_RECORD_TYPE, start, end);
    final List<Statement> assignments = new ArrayList<>();
    assignments.add(paramsField.putInstanceField(thisVar, paramsVar));
    assignments.add(ijField.putInstanceField(thisVar, ijVar));
    for (TemplateParam param : templateNode.getAllParams()) {
      Expression paramProvider =
          getParam(paramsVar, ijVar, param, defaultParamInitializers.get(param));
      assignments.add(paramFields.get(param.name()).putInstanceField(thisVar, paramProvider));
    }
    Statement constructorBody =
        new Statement() {
          @Override
          protected void doGen(CodeBuilder ga) {
            ga.mark(start);
            // call super()
            thisVar.gen(ga);
            ga.invokeConstructor(OBJECT.type(), NULLARY_INIT);
            for (Statement assignment : assignments) {
              assignment.gen(ga);
            }
            ga.visitInsn(Opcodes.RETURN);
            ga.visitLabel(end);
            thisVar.tableEntry(ga);
            paramsVar.tableEntry(ga);
            ijVar.tableEntry(ga);
          }
        };
    constructorBody.writeMethod(Opcodes.ACC_PUBLIC, template.constructor().method(), writer);
  }
644436
private <J, T extends Proxy<J>> T marshalConstructor(final int opcode,
                                                         final J implementation,
                                                         final int version,
                                                         final Class<T> newProxyCls,
                                                         final long argsPointer) {
        try {
            final long wlProxy = WaylandClientCore.INSTANCE()
                                                  .wl_proxy_marshal_array_constructor(this.pointer,
                                                                                      opcode,
                                                                                      argsPointer,
                                                                                      InterfaceMeta.get(newProxyCls).pointer.address);
            return marshalProxy(wlProxy,
                                implementation,
                                version,
                                newProxyCls);
        }
        catch (final NoSuchMethodException |
                IllegalAccessException |
                InstantiationException |
                InvocationTargetException e) {
            throw new RuntimeException("Uh oh, this is a bug!",
                                       e);
        }
    }
150002
@Override
    public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
        if (SplitlogLoggerFactory.isLoggingEnabled()) {
            SplitlogLoggerFactory.increaseMessageCounter();
            return method.invoke(this.proxied, args);
        } else {
            // logging is not enabled, don't proxy the call
            return null;
        }
    }
1208704
private MethodHandle findConstructor() {
    try {
      MethodHandle mh = MethodHandles.publicLookup().findConstructor(clazz,
          MethodType.methodType(void.class, getIdType()));
      return mh;
    } catch (NoSuchMethodException | IllegalAccessException exp) {
      String pattern = "Class %s requires a public constructor with one parameter of type %s";
      String error = String.format(pattern, clazz.getName(), getIdType());
      throw new EntityManagerException(error, exp);
    }
  }
937266
@Override
    public Constructor<T> getConstructor() {
        if (this.constructor == null) {
            try {
                this.constructor = this.managedClass.getConstructor((Class<?>[]) null);
            } catch (NoSuchMethodException e) {
                throw new IllegalStateException(e);
            }
        }
        return this.constructor;
    }
979241
public static Constructor<?>[] getAllConstructors(Class<?> clazz) {
        Constructor<?>[] declaredConstructors = clazz.getDeclaredConstructors();
        for (Constructor<?> constructor : declaredConstructors) {
            if (!constructor.isAccessible()) {
                constructor.setAccessible(true);
            }
        }
        return declaredConstructors;
    }
1098376
@Override
  public Object invokeMethod(String name, Object[] args) {
    ISlot slot = findSlot(name, args);
    PojoGestalt gestalt = createGestalt(slot.getType(), args);
    new Sculpturer().$form(gestalt);
    slot.write(gestalt.getSubject());
    return gestalt.getSubject();
  }
1163017
@Override
    @Trivial
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        if ("addTransformer".equals(method.getName())) {
            addTransformer((ClassFileTransformer) args[0], args.length > 1 ? (Boolean) args[1] : false);
            return null;
        }
        if ("removeTransformer".equals(method.getName())) {
            return removeTransformer((ClassFileTransformer) args[0]);
        }
        if ("appendToBootstrapClassLoaderSearch".equals(method.getName())) {
            appendToBootstrapClassLoaderSearch((JarFile) args[0]);
            return null;
        }
        if ("appendToSystemClassLoaderSearch".equals(method.getName())) {
            appendToSystemClassLoaderSearch((JarFile) args[0]);
            return null;
        }
        if ("setNativeMethodPrefix".equals(method.getName())) {
            setNativeMethodPrefix((ClassFileTransformer) args[0], (String) args[1]);
            return null;
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.entry(tc, method.getName(), args);
        }

        Object retValue = method.invoke(instrumentation, args);

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            if (void.class == method.getReturnType()) {
                Tr.exit(tc, method.getName());
            } else {
                Tr.exit(tc, method.getName(), retValue);
            }
        }
        return retValue;
    }
1117214
@Override
    public <T> T invoke(Context context, Class<T> classOfT) {
        return invoke(context, classOfT, null);
    }