/** * Produce the correct bytecode to build an array. The opcode to use and the * signature to pass along with the opcode can vary depending on the signature * of the array type. * @param mv the methodvisitor into which code should be inserted * @param size the size of the array * @param arraytype the type of the array */ public static void insertNewArrayCode(MethodVisitor mv, int size, String arraytype) { insertOptimalLoad(mv, size); if (arraytype.length() == 1) { mv.visitIntInsn(NEWARRAY, CodeFlow.arrayCodeFor(arraytype)); } else { if (arraytype.charAt(0) == '[') { // Handling the nested array case here. // If vararg is [[I then we want [I and not [I; if (CodeFlow.isReferenceTypeArray(arraytype)) { mv.visitTypeInsn(ANEWARRAY, arraytype + ";"); } else { mv.visitTypeInsn(ANEWARRAY, arraytype); } } else { mv.visitTypeInsn(ANEWARRAY, arraytype.substring(1)); } } }
/** * Produce the correct bytecode to build an array. The opcode to use and the * signature to pass along with the opcode can vary depending on the signature * of the array type. * @param mv the methodvisitor into which code should be inserted * @param size the size of the array * @param arraytype the type of the array */ public static void insertNewArrayCode(MethodVisitor mv, int size, String arraytype) { insertOptimalLoad(mv, size); if (arraytype.length() == 1) { mv.visitIntInsn(NEWARRAY, CodeFlow.arrayCodeFor(arraytype)); } else { if (arraytype.charAt(0) == '[') { // Handling the nested array case here. // If vararg is [[I then we want [I and not [I; if (CodeFlow.isReferenceTypeArray(arraytype)) { mv.visitTypeInsn(ANEWARRAY, arraytype + ";"); } else { mv.visitTypeInsn(ANEWARRAY, arraytype); } } else { mv.visitTypeInsn(ANEWARRAY, arraytype.substring(1)); } } }
/** * Produce the correct bytecode to build an array. The opcode to use and the * signature to pass along with the opcode can vary depending on the signature * of the array type. * @param mv the methodvisitor into which code should be inserted * @param size the size of the array * @param arraytype the type of the array */ public static void insertNewArrayCode(MethodVisitor mv, int size, String arraytype) { insertOptimalLoad(mv, size); if (arraytype.length() == 1) { mv.visitIntInsn(NEWARRAY, CodeFlow.arrayCodeFor(arraytype)); } else { if (arraytype.charAt(0) == '[') { // Handling the nested array case here. // If vararg is [[I then we want [I and not [I; if (CodeFlow.isReferenceTypeArray(arraytype)) { mv.visitTypeInsn(ANEWARRAY, arraytype + ";"); } else { mv.visitTypeInsn(ANEWARRAY, arraytype); } } else { mv.visitTypeInsn(ANEWARRAY, arraytype.substring(1)); } } }