Example usage for org.objectweb.asm Type equals

List of usage examples for org.objectweb.asm Type equals

Introduction

In this page you can find the example usage for org.objectweb.asm Type equals.

Prototype

@Override
public boolean equals(final Object object) 

Source Link

Document

Tests if the given object is equal to this type.

Usage

From source file:asmlib.InfoMethodVisitor.java

License:Open Source License

@Override
public void visitFieldInsn(int opcode, String owner, String name, String desc) {
    Type ownerClass = Type.fromAsm(owner);
    if (!ownerClass.equals(_method.infoClass().type())) {
        // Mtodo acede a fields de outras classes!
        _method.setAccessesOutsideFields(true);
    }//w  w  w. j a v  a2 s  . c o  m
}

From source file:boilerplate.processor.adapters.EqualsAdapter.java

License:Open Source License

@Override
public AnnotationVisitor visitAnnotation(String name, boolean visible) {
    Type type = Type.getType(name);
    Type annotationType = Type.getType(AutoEquals.class);
    if (type.equals(annotationType)) {
        typeInfo.typeIsAnnotated = true;
    }/*from   w  ww .  ja va  2 s.c  o  m*/

    return super.visitAnnotation(name, visible);
}

From source file:boilerplate.processor.adapters.ToStringAdapter.java

License:Open Source License

@Override
public AnnotationVisitor visitAnnotation(String name, boolean visible) {
    Type type = Type.getType(name);
    Type annotationType = Type.getType(AutoToString.class);
    if (type.equals(annotationType)) {
        typeInfo.typeIsAnnotated = true;
    }/*from   ww w  .j a  v  a2s  . com*/

    return super.visitAnnotation(name, visible);
}

From source file:ca.weblite.asm.JavaExtendedStubCompiler.java

License:Apache License

public Map<String, byte[]> compile(List<Type> types, File sourceFile) throws IOException {
    final Map<String, byte[]> outMap = new HashMap<>();
    final Set<String> typeNames = (types == null) ? null : new HashSet<String>();
    if (types != null) {
        for (Type type : types) {
            typeNames.add(type.getInternalName());
        }/*from  w  w w .  j a  v  a 2 s. co  m*/
    }
    JavaCompiler compiler = JavacTool.create();
    MyFileObject[] fos = new MyFileObject[] { new MyFileObject(sourceFile) };

    JavacTask task = (JavacTask) compiler.getTask(null, null, null, null, null, Arrays.asList(fos));
    Iterable<? extends CompilationUnitTree> asts = task.parse();
    TreePathScanner scanner;

    final LinkedList<ClassFinder> scopeStack = new LinkedList<>();
    scanner = new TreePathScanner() {

        String packageName;
        ClassNode superClass;
        LinkedList<String> stack = new LinkedList<>();
        LinkedList<ClassInfo> classInfoStack = new LinkedList<>();
        LinkedList<ClassWriter> cwStack = new LinkedList<>();
        LinkedList<List<? extends TypeParameterTree>> typeParametersStack = new LinkedList<>();

        @Override
        public Object visitCompilationUnit(CompilationUnitTree cut, Object p) {

            packageName = cut.getPackageName().toString();
            ClassFinder scope = new ClassFinder(context.get(ClassLoader.class), null);
            scopeStack.push(scope);
            scope.addImport(packageName + ".*");
            return super.visitCompilationUnit(cut, p);
        }

        private String getThisInternalName(String simpleName) {
            simpleName = simpleName.replaceAll("\\.", "$");
            StringBuilder sb = new StringBuilder();
            Iterator<String> it = stack.descendingIterator();
            sb.append(packageName.replaceAll("\\.", "/"));
            sb.append("/");

            while (it.hasNext()) {
                sb.append(it.next()).append("$");
            }
            sb.append(simpleName);
            return sb.toString();
        }

        @Override
        public Object visitImport(ImportTree it, Object p) {
            if (!it.isStatic()) {
                String path = it.getQualifiedIdentifier().toString();
                scopeStack.peek().addImport(path);
            }
            return super.visitImport(it, p);
        }

        Object visitConstructor(final MethodTree mt, Object p) {
            ClassWriter classWriter = cwStack.peek();
            List<Type> argTypes = new ArrayList<Type>();
            boolean isVarArgs = false;
            for (VariableTree v : mt.getParameters()) {

                if (v.toString().endsWith("... " + v.getName())) {
                    isVarArgs = true;
                }
                String type = v.getType().toString();
                String fullType = type;
                String signature = null;
                try {
                    signature = TypeUtil.getTypeSignature(type, scopeStack.peek());
                } catch (Throwable t) {
                    System.out.println("Failed to find signature for type");
                }
                if (type.indexOf("<") != -1) {
                    type = type.substring(0, type.indexOf("<"));
                }
                int dim = 0;
                if (TypeUtil.isArrayType(type)) {
                    dim = TypeUtil.getArrayTypeDimension(type);
                    type = TypeUtil.getArrayElementType(type);
                }
                if (TypeUtil.isPrimitiveType(type)) {
                    String descriptor = TypeUtil.getDescriptor(type);
                    argTypes.add(Type.getType(TypeUtil.getArrayDescriptor(descriptor, dim)));
                } else {
                    ClassNode stub = scopeStack.peek().findStub(type);
                    assert stub != null;
                    argTypes.add(Type.getObjectType(stub.name));
                }

            }

            String methodDescriptor = null;
            String methodSignature = null;
            if (argTypes.isEmpty()) {
                methodDescriptor = Type.getMethodDescriptor(Type.getType("V"));
            } else {
                methodDescriptor = Type.getMethodDescriptor(Type.getType("V"), argTypes.toArray(new Type[0]));

            }

            int flags = getFlags(mt.getModifiers().getFlags());
            if (isVarArgs) {
                flags |= Opcodes.ACC_VARARGS;

            }
            classWriter.visitMethod(flags, mt.getName().toString(), methodDescriptor, null, null);
            classInfoStack.peek().numConstructors++;
            return null;
        }

        @Override
        public Object visitMethod(MethodTree mt, Object p) {
            if (mt.getReturnType() == null) {
                // It's a constructor
                return visitConstructor(mt, p);
            } else {
                boolean isVarArgs = false;
                ClassWriter classWriter = cwStack.peek();

                List<Type> argTypes = new ArrayList<>();
                List<String> sigArgTypes = new ArrayList<>();
                for (VariableTree v : mt.getParameters()) {
                    String type = v.getType().toString();
                    if (v.toString().endsWith("... " + v.getName())) {
                        isVarArgs = true;
                    }
                    sigArgTypes.add(type);
                    int dim = 0;
                    if (TypeUtil.isArrayType(type)) {
                        dim = TypeUtil.getArrayTypeDimension(type);
                        type = TypeUtil.getArrayElementType(type);
                    }
                    if (TypeUtil.isPrimitiveType(type)) {
                        String descriptor = TypeUtil.getDescriptor(type);
                        argTypes.add(Type.getType(TypeUtil.getArrayDescriptor(descriptor, dim)));
                    } else {

                        if (isGenericType(type)) {
                            type = "Object";
                        }

                        int arrowPos = type.indexOf("<");
                        if (arrowPos != -1) {
                            type = type.substring(0, arrowPos);
                        }
                        ClassNode stub = scopeStack.peek().findStub(type);
                        if (stub == null) {
                            throw new RuntimeException("Could not find class for " + type);
                        }
                        Type argType = Type.getObjectType(stub.name);
                        argType = Type.getType(TypeUtil.getArrayDescriptor(argType.getInternalName(), dim));
                        argTypes.add(argType);
                    }

                }

                String returnType = mt.getReturnType().toString();
                if (isGenericType(returnType)) {
                    returnType = "Object";
                }

                String methodSignature = null;
                try {
                    methodSignature = TypeUtil.getMethodSignature(scopeStack.peek(), returnType,
                            sigArgTypes.toArray(new String[0]));
                } catch (Exception ex) {
                    System.out.println(
                            "Failed to get signature for method " + mt + " message: " + ex.getMessage());
                }
                int dim = 0;

                Type returnTypeType = null;
                if (TypeUtil.isArrayType(returnType)) {
                    dim = TypeUtil.getArrayTypeDimension(returnType);
                    returnType = TypeUtil.getArrayElementType(returnType);
                    if (isGenericType(returnType)) {
                        returnType = "Object";
                    }

                }
                if (TypeUtil.isPrimitiveType(returnType)) {
                    String descriptor = TypeUtil.getDescriptor(returnType);
                    returnTypeType = Type.getType(TypeUtil.getArrayDescriptor(descriptor, dim));

                } else {
                    int arrowPos = returnType.indexOf("<");
                    if (arrowPos != -1) {
                        returnType = returnType.substring(0, arrowPos);
                    }
                    ClassNode stub = scopeStack.peek().findStub(returnType);
                    if (stub == null) {
                        System.out.println("Type params is " + mt.getTypeParameters());
                        System.out.println("Type kind is " + mt.getReturnType().getKind());
                        throw new RuntimeException("Could not find class for " + returnType);
                    }

                    returnTypeType = Type.getObjectType(stub.name);
                    returnTypeType = Type
                            .getType(TypeUtil.getArrayDescriptor(returnTypeType.getInternalName(), dim));

                }

                String methodDescriptor = null;
                if (argTypes.isEmpty()) {
                    methodDescriptor = Type.getMethodDescriptor(returnTypeType);
                } else {
                    methodDescriptor = Type.getMethodDescriptor(returnTypeType, argTypes.toArray(new Type[0]));
                }

                int flags = getFlags(mt.getModifiers().getFlags());
                if (isVarArgs) {
                    flags |= Opcodes.ACC_VARARGS;
                    //System.out.println("VarArgs "+flags);
                }
                classWriter.visitMethod(flags, mt.getName().toString(), methodDescriptor, methodSignature,
                        null);

            }
            //methodStack.push(mt);
            //Object out= super.visitMethod(mt, p); 
            //methodStack.pop();
            return null;
        }

        //private boolean LinkedList<MethodTree> methodStack  =new LinkedList<>();
        @Override
        public Object visitVariable(VariableTree vt, Object p) {

            ClassWriter classWriter = cwStack.peek();

            String varType = vt.getType().toString();
            if (isGenericType(varType)) {
                varType = "Object";
            }
            String signature = null;
            try {
                signature = TypeUtil.getTypeSignature(varType, scopeStack.peek());
            } catch (Exception ex) {
                System.out.println("Failed to generate signature for type " + varType);
            }
            int dim = 0;

            Type varTypeType = null;
            if (TypeUtil.isArrayType(varType)) {
                dim = TypeUtil.getArrayTypeDimension(varType);
                varType = TypeUtil.getArrayElementType(varType);

            }
            if (TypeUtil.isPrimitiveType(varType)) {
                String descriptor = TypeUtil.getDescriptor(varType);
                varTypeType = Type.getType(TypeUtil.getArrayDescriptor(descriptor, dim));

            } else {
                int arrowPos = varType.indexOf("<");
                if (arrowPos != -1) {
                    varType = varType.substring(0, arrowPos);
                }
                ClassNode stub = scopeStack.peek().findStub(varType);
                if (stub == null) {
                    throw new RuntimeException("Could not find class for " + varType);
                }

                varTypeType = Type.getObjectType(stub.name);
                varTypeType = Type.getType(TypeUtil.getArrayDescriptor(varTypeType.getInternalName(), dim));

            }

            classWriter.visitField(getFlags(vt.getModifiers().getFlags()), vt.getName().toString(),
                    varTypeType.toString(), signature, null);

            return super.visitVariable(vt, p); //To change body of generated methods, choose Tools | Templates.
        }

        boolean isGenericType(String type) {
            for (List<? extends TypeParameterTree> types : typeParametersStack) {
                for (TypeParameterTree tree : types) {
                    if (type.equals(tree.getName().toString())) {
                        return true;
                    }
                }
            }
            return false;
        }

        /**
         * Converts modifier flags from Javac Tree into int flags usable in 
         * TypeMirror
         * @param mods
         * @return 
         */
        int getFlags(Set<Modifier> mods) {
            int flags = 0;
            for (Modifier m : mods) {
                switch (m) {
                case ABSTRACT:
                    flags |= Opcodes.ACC_ABSTRACT;
                    break;
                case FINAL:
                    flags |= Opcodes.ACC_FINAL;
                    break;
                case PRIVATE:
                    flags |= Opcodes.ACC_PRIVATE;
                    break;
                case PROTECTED:
                    flags |= Opcodes.ACC_PROTECTED;
                    break;
                case PUBLIC:

                    flags |= Opcodes.ACC_PUBLIC;
                    break;
                case STATIC:
                    flags |= Opcodes.ACC_STATIC;
                    break;

                }
            }

            return flags;
        }

        @Override
        public Object visitClass(ClassTree ct, Object p) {
            //System.out.println("Visiting class "+ct);
            //System.out.println("Type parameters: "+ct.getTypeParameters());
            typeParametersStack.push(ct.getTypeParameters());
            String simpleName = ct.getSimpleName().toString();
            String internalName = getThisInternalName(simpleName);
            int lastDollar = internalName.lastIndexOf("$");
            String externalName = lastDollar == -1 ? null : internalName.substring(0, lastDollar);
            String supername = "java.lang.Object";
            String[] interfaces = null;
            boolean targetClass = false;
            if (!cwStack.isEmpty()) {
                cwStack.peek().visitInnerClass(internalName, externalName, simpleName,
                        getFlags(ct.getModifiers().getFlags()));
            }

            targetClass = true;
            // This is the one that we'
            //String supername = "java.lang.Object";
            if (ct.getExtendsClause() != null) {
                supername = ct.getExtendsClause().toString().trim();
            }
            String unresolvedSuperName = supername;

            int bracketPos = supername.indexOf("<");
            supername = bracketPos == -1 ? supername : supername.substring(0, bracketPos);
            ClassNode node = scopeStack.peek().findStub(supername);
            if (node == null) {
                throw new RuntimeException("Could not find super stub " + supername);
            }
            supername = node.name;

            String impl = ct.getImplementsClause().toString();
            String[] unresolvedInterfaces = null;
            if (impl != null && !"".equals(impl)) {
                interfaces = impl.split(",");
                unresolvedInterfaces = new String[interfaces.length];
                for (int i = 0; i < interfaces.length; i++) {

                    String iface = interfaces[i];
                    unresolvedInterfaces[i] = interfaces[i];
                    iface = iface.trim();
                    ClassNode inode = scopeStack.peek().findStub(iface);
                    assert inode != null;
                    if (inode == null) {
                        throw new RuntimeException("Could not find stub for interface " + iface);
                    }
                    System.out.println("interface " + iface);
                    interfaces[i] = inode.name;
                }
            }
            String signature = TypeUtil.getClassSignature(scopeStack.peek(), null, unresolvedSuperName,
                    unresolvedInterfaces);
            int flags = getFlags(ct.getModifiers().getFlags());

            switch (ct.getKind()) {
            case INTERFACE:
                flags |= Opcodes.ACC_INTERFACE;
                break;

            case ENUM:
                flags |= Opcodes.ACC_ENUM;
                break;

            }

            ClassWriter classWriter = new ClassWriter(49);
            classWriter.visit(49, flags, internalName, signature, supername, interfaces

            );
            cwStack.push(classWriter);
            classInfoStack.push(new ClassInfo());
            stack.push(simpleName);
            ClassFinder scope = new ClassFinder(context.get(ClassLoader.class), scopeStack.peek());

            scope.addImport(internalName.replaceAll("/", ".").replaceAll("\\$", ".") + ".*"

            );
            scope.addImport(internalName.replaceAll("/", ".").replaceAll("\\$", "."));
            scope.addImport(supername.replaceAll("/", ".").replaceAll("\\$", ".") + ".*"

            );
            scope.addImport(supername.replaceAll("/", ".").replaceAll("\\$", "."));

            if (interfaces != null) {
                for (int i = 0; i < interfaces.length; i++) {
                    scope.addImport(interfaces[i].replaceAll("/", ".").replaceAll("\\$", ".") + ".*"

                    );
                    scope.addImport(interfaces[i].replaceAll("/", ".").replaceAll("\\$", "."));
                }
            }
            for (TypeParameterTree tpTree : ct.getTypeParameters()) {
                //System.out.println("Name: "+tpTree.getName());
                //System.out.println("Kind: "+tpTree.getKind().name());
                //System.out.println("Bounds: "+tpTree.getBounds());
                String bounds = (tpTree.getBounds() != null && !tpTree.getBounds().isEmpty())
                        ? tpTree.getBounds().get(0).toString()
                        : "java.lang.Object";
                scope.addTypeParameter(tpTree.getName().toString(), bounds);
            }
            scopeStack.push(scope);
            Object out = super.visitClass(ct, p);
            stack.pop();
            scopeStack.pop();
            ClassInfo classInfo = classInfoStack.pop();
            if (classInfo.numConstructors == 0) {
                // there are no declared constructors in this class 
                // we need to add a default constructor.
                cwStack.peek().visitMethod(Opcodes.ACC_PUBLIC, "<init>",
                        Type.getMethodDescriptor(Type.getType("V")), null, null);
                classInfo.numConstructors++;
            }

            if (targetClass) {
                byte[] bytes = cwStack.peek().toByteArray();
                outMap.put(internalName, bytes);
                cwStack.pop();
            }

            typeParametersStack.pop();

            return out;
        }

    };
    scanner.scan(asts, null);
    return outMap;
}

From source file:ch.eiafr.cojac.FloatReplacerMethodVisitor.java

License:Apache License

@Override
public void visitFieldInsn(int opcode, String owner, String name, String desc) {
    if (references.hasToBeInstrumented(owner) == false) { // proxy for fields
        Type type = Type.getType(desc);
        Type cojacType = afterFloatReplacement(type);
        if (type.equals(cojacType) == false) { // the type is being changed
            if (opcode == GETFIELD || opcode == GETSTATIC) {
                mv.visitFieldInsn(opcode, owner, name, desc);
                FloatProxyMethod.convertRealToCojacType(type, mv);
                return;
            }/*  www  .  j a  v a2s .co m*/
            if (opcode == PUTFIELD || opcode == PUTSTATIC) {
                FloatProxyMethod.convertCojacToRealType(type, mv);
                mv.visitFieldInsn(opcode, owner, name, desc);
                return;
            }
        }
    }

    String descAfter = afterFloatReplacement(desc);
    if (!desc.equals(descAfter))
        stats.incrementCounterValue(opcode);
    mv.visitFieldInsn(opcode, owner, name, descAfter);

    // TODO - handle GETSTATIC & handle std_lib and already loaded classes
    if (opcode == GETFIELD) {
        String objDesc = Type.getType(Object.class).getDescriptor();
        if (descAfter.equals(COJAC_DOUBLE_WRAPPER_TYPE_DESCR)) {
            mv.visitMethodInsn(INVOKESTATIC, DN_NAME, "initialize", "(" + objDesc + ")" + objDesc, false);
            mv.visitTypeInsn(CHECKCAST, COJAC_DOUBLE_WRAPPER_INTERNAL_NAME);
        }
        if (descAfter.equals(COJAC_FLOAT_WRAPPER_TYPE_DESCR)) {
            mv.visitMethodInsn(INVOKESTATIC, FN_NAME, "initialize", "(" + objDesc + ")" + objDesc, false);
            mv.visitTypeInsn(CHECKCAST, COJAC_FLOAT_WRAPPER_INTERNAL_NAME);
        }
    }
}

From source file:ch.eiafr.cojac.FloatReplacerMethodVisitor.java

License:Apache License

@Override
public void visitTypeInsn(int opcode, String type) {
    // BAPST: that's where we instrument NEW Double/Float...
    Type myType = Type.getObjectType(type); // get type from internal name

    Type cojacType = afterFloatReplacement(myType);

    if (opcode == CHECKCAST && myType.equals(cojacType) == false) {
        if (stackTop().equals(Type.getType(Object.class).getInternalName())) {
            if (cojacType.equals(COJAC_FLOAT_WRAPPER_TYPE)) {
                mv.visitMethodInsn(INVOKESTATIC, FN_NAME, "castFromObject",
                        "(" + Type.getType(Object.class).getDescriptor() + ")"
                                + Type.getType(Object.class).getDescriptor(),
                        false);/*  www.jav a  2 s.  c om*/
            }
            if (cojacType.equals(COJAC_DOUBLE_WRAPPER_TYPE)) {
                mv.visitMethodInsn(INVOKESTATIC, DN_NAME, "castFromObject",
                        "(" + Type.getType(Object.class).getDescriptor() + ")"
                                + Type.getType(Object.class).getDescriptor(),
                        false);
            }
        }
    }

    mv.visitTypeInsn(opcode, cojacType.getInternalName());
}

From source file:ch.eiafr.cojac.FloatVariablesSorter.java

License:Apache License

public FloatVariablesSorter(int access, String oldDesc, AnalyzerAdapter mv) {
    super(Opcodes.ASM5, mv);
    Type[] args = Type.getArgumentTypes(oldDesc);
    firstFrameMapping = new int[1 + args.length * 2]; // +1 for 'this'
    Arrays.fill(firstFrameMapping, -1); // so that erroneously using unwritten cells will cause problems...
    boolean hasTarget = (Opcodes.ACC_STATIC & access) == 0; // not static -> there is a 'this' param
    int oldVarIndex = 0;
    int newVarIndex = 0;
    int lastIndexSet = -1;
    if (hasTarget) {
        oldVarIndex = newVarIndex = 1;//from  w  w  w  .  ja  va 2s.co  m
        firstFrameMapping[0] = 0; // 'this' remains 'this' after remapping...
        lastIndexSet = 0;
    }
    for (Type arg : args) {
        firstFrameMapping[oldVarIndex] = newVarIndex;
        lastIndexSet = oldVarIndex;
        oldVarIndex += arg.getSize();
        newVarIndex += arg.getSize();
        if (arg.equals(Type.DOUBLE_TYPE)) {
            newVarIndex--;
        }
        assert !arg.equals(COJAC_DOUBLE_WRAPPER_TYPE); // this would be strange (the descriptor is the old one)
    }
    maxRenumber = lastIndexSet;
}

From source file:ch.eiafr.cojac.instrumenters.FloatProxyMethod.java

License:Apache License

private static void maybeConvertTarget(MethodVisitor mv, int opcode, String owner) {
    // stack >> [target] allParamsArr
    if (!hasTarget(opcode))
        return;/*from  w w w .j av  a 2  s.com*/
    // stack >> target allParamsArr
    if (opcode != INVOKEVIRTUAL)
        return; // not sure for invokeinterface or invokedynamic...
    if (owner.equals(JWRAPPER_FLOAT_TYPE.getInternalName())) {
        mv.visitInsn(SWAP);
        convertCojacToRealType(JWRAPPER_FLOAT_TYPE, mv);
        mv.visitInsn(SWAP);
    } else if (owner.equals(JWRAPPER_DOUBLE_TYPE.getInternalName())) {
        mv.visitInsn(SWAP);
        convertCojacToRealType(JWRAPPER_DOUBLE_TYPE, mv);
        mv.visitInsn(SWAP);
    }
    Type ownerType = Type.getType(owner); // that case doesn't contain the preceding two
    Type afterType = afterFloatReplacement(ownerType);
    if (!ownerType.equals(afterType)) {
        mv.visitInsn(SWAP);
        convertCojacToRealType(ownerType, mv);
        mv.visitInsn(SWAP);
    }
    // stack >> [newTarget] allParamsArr
}

From source file:ch.eiafr.cojac.instrumenters.FloatProxyMethod.java

License:Apache License

private static void convertReturnType(MethodVisitor mv, String desc) {
    Type returnType = Type.getReturnType(desc);
    Type cojacType = afterFloatReplacement(returnType);
    if (returnType.equals(cojacType) == false) {
        convertRealToCojacType(returnType, mv);
    }/*from w w  w  . jav  a  2  s.c  om*/
    if (returnType.equals(OBJ_TYPE)) {
        convertObjectToCojac(mv, returnType);
    } else if (returnType.getSort() == Type.ARRAY && returnType.getElementType().equals(OBJ_TYPE)) {
        convertObjectToCojac(mv, returnType);
    }
}

From source file:ch.eiafr.cojac.instrumenters.FloatProxyMethod.java

License:Apache License

private void createConvertMethod(String convertDesc, ConversionContext cc) {
    if (ccv.isProxyMethod(COJAC_TYPE_CONVERT_NAME, convertDesc))
        return; // the method already exists
    MethodVisitor newMv = ccv.addProxyMethod(ACC_STATIC, COJAC_TYPE_CONVERT_NAME, convertDesc, null, null);
    int varIndex = 0;
    newMv.visitLdcInsn(cc.outArgs.length + 1); // additional cell for the AllAsObjects array
    newMv.visitTypeInsn(ANEWARRAY, OBJ_TYPE.getInternalName());
    // stack >> prmsArr
    newMv.visitInsn(DUP);// w  w w .ja va2  s  . c  om
    newMv.visitLdcInsn(cc.outArgs.length);
    newMv.visitInsn(DUP);
    newMv.visitTypeInsn(ANEWARRAY, OBJ_TYPE.getInternalName());
    // stack >> prmsArr prmsArr n asObjArr
    newMv.visitInsn(AASTORE);
    // stack >> prmsArr

    for (int i = 0; i < cc.outArgs.length; i++) {
        Type ia = cc.inArgs[i];
        newMv.visitInsn(DUP);
        newMv.visitInsn(DUP);
        newMv.visitLdcInsn(cc.outArgs.length);
        // stack >> prmsArr prmsArr prmsArr n
        newMv.visitInsn(AALOAD);
        newMv.visitTypeInsn(CHECKCAST, "[" + OBJ_TYPE.getDescriptor());
        // stack >> prmsArr prmsArr asObjArr
        newMv.visitLdcInsn(i);
        // stack >> prmsArr prmsArr asObjArr i
        newMv.visitVarInsn(getLoadOpcode(ia), varIndex);
        convertPrimitiveToObject(newMv, cc.inArgs[i]);
        // stack >> prmsArr prmsArr asObjArr i pi
        newMv.visitInsn(AASTORE);
        // stack >> prmsArr prmsArr
        newMv.visitLdcInsn(i);
        // stack >> prmsArr prmsArr i
        newMv.visitVarInsn(getLoadOpcode(ia), varIndex);
        varIndex += cc.inArgs[i].getSize();
        // stack >> prmsArr prmsArr i pi
        boolean keepBothVersions = (ia.getSort() == Type.ARRAY);
        if (keepBothVersions) { // keep the old reference (the Cojac one)
            newMv.visitLdcInsn(2);
            newMv.visitTypeInsn(ANEWARRAY, OBJ_TYPE.getInternalName());
            // stack >> prmsArr prmsArr i pi piArr
            newMv.visitInsn(DUP_X1);
            // stack >> prmsArr prmsArr i piArr pi piArr
            newMv.visitInsn(SWAP);
            // stack >> prmsArr prmsArr i piArr piArr pi
            newMv.visitInsn(DUP_X1);
            newMv.visitLdcInsn(0);
            newMv.visitInsn(SWAP);
            // stack >> prmsArr prmsArr i piArr pi piArr pi 0
            newMv.visitInsn(AASTORE);
            // stack >> prmsArr prmsArr i piArr
        }
        // stack >> prmsArr prmsArr i pi
        if (cc.needsConversion(i)) {
            convertCojacToRealType(cc.asOriginalJavaType(i), newMv);
        } else if (cc.shouldObjParamBeConverted && (ia.equals(OBJ_TYPE) || ia.equals(OBJ_ARRAY_TYPE))) {
            convertObjectToReal(newMv, ia);
        }
        /* This is where we could decide to convert back to JavaWrapper
         * when the argument is declared as Object
         * We don't do that to keep "enriched numbers" in collections
         * but sometimes we would like to convert, eg printf, format...
         */
        convertPrimitiveToObject(newMv, cc.outArgs[i]);
        // stack >> prmsArr prmsArr i pi
        if (keepBothVersions) { // keep the new reference (the java one)
            newMv.visitInsn(SWAP);
            newMv.visitInsn(DUP_X1);
            newMv.visitInsn(SWAP);
            newMv.visitLdcInsn(1);
            newMv.visitInsn(SWAP);
            newMv.visitInsn(AASTORE);
        }
        // stack >> prmsArr prmsArr i pi
        newMv.visitInsn(AASTORE);
        // stack >> prmsArr
    }
    newMv.visitInsn(ARETURN);
    newMv.visitMaxs(0, 0);
}